-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Is your feature request related to a problem? Please describe.
For better defining the otel-collector-config.yml
, a JSON schema would be great to validate the configuration before using it in the collector itself.
Describe the solution you'd like
A JSON Schema for validating the configuration when writing it, similarly to Docker compose files or Kubernetes manifest files, ...
Describe alternatives you've considered
Reading the docs multiple times, and checking config by running it on local cluster w/ Docker compose or Kubernetes.
bateller, wbh1, asweet-confluent and GtrMo
Metadata
Metadata
Assignees
Labels
No labels
Activity
TylerHelmuth commentedon Mar 15, 2024
@TylerHelmuth If I understand json schema correctly you could write a schema file and use it to validate the config externally (not inside the collector) correct?
LBF38 commentedon Mar 16, 2024
Yes, the configuration file in
.yml
will be statically checked against the JSON Schema, therefore providing an easier way to configure all the possible aspects of the otel collector.You can try this out with a
compose.yml
file for defining Docker compose stacks, for example. And you will see that you get automatic intellisense on defining the important parts of the configuration.And, in your schema, you can define if a property is required or not and his types.
TylerHelmuth commentedon Mar 16, 2024
I recommend you write and maintain your own file specific to your collector build.
Since the collector is composable from components from anywhere, and those components can use any configuration they want, it isn't possible for us to provide a single, wholistic, schema file for any collector build.
We could maybe provide one with each distro we provide, but even that would be hard to maintain.
yurishkuro commentedon Mar 16, 2024
related, but closed issue open-telemetry/opentelemetry-collector-contrib#27003
yurishkuro commentedon Mar 16, 2024
@TylerHelmuth I disagree with your DIY position. The advantage of OTEL collector for custom distros is in providing a reusable baseline. From my perspective the discoverability of configuration of different components is very bad today, 2 out of 5. A DIY approach cannot solve for the lack of schema / documentation of existing components, it needs to be solved centrally in the main collector repo. JSON schema is one option, I personally would prefer protobuf schema (either would need a prototype to iron out kinks), as I mentioned in open-telemetry/opentelemetry-collector-contrib#27003 (comment)
TylerHelmuth commentedon Mar 16, 2024
@yurishkuro I agree that we could improve the consistency and quality of component documentation - being able to auto-generate standard docs from component config would be awesome.
What I'm arguing is that the Collector Core repo cannot supply a single schema file that could be used to statically validate any collector build.
Each distribution at https://github.com/open-telemetry/opentelemetry-collector-releases could maybe supply a schema that knows about each component in its manifest. Maybe the collector could add an extra command to generate a schema file based on the supplied config.
yurishkuro commentedon Mar 16, 2024
agreed, but if there was a standard mechanism defined & used in Core it would be much more likely that components and contrib plugins would start using it to declare their configuration, improving the overall ecosystem.
cforce commentedon Mar 17, 2024
With schema support issue #9707 would be based upon
cmgriffing commentedon Mar 17, 2024
I think this would improve the experience quite a bit.
As further info, if the JSON Schema were uploaded to SchemaStore.org, various tools and editors would get automatic support in their various plugins.
https://www.schemastore.org/json/#editors
As an example, this VSCode YAML extension would be able to consume it:
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
While I understand the concerns for extensibility, a JSON schema can allow arbitrary fields in addition to the official fields. So there is nothing lost if a different tool wants to add custom config.
LBF38 commentedon Apr 5, 2024
Hi everyone,
After exploring more related issues and work on this topic, I will try to summarize my findings in this comment.
Auto Generation of Component Configuration from metadata.yaml opentelemetry-collector-contrib#27003
Automate reference documentation as YAML or JSON opentelemetry-collector-contrib#24189
https://github.com/open-telemetry/opentelemetry-configuration
[Proposal] Automate reference documentation as YAML files community#1610
https://github.com/splunk/collector-config-tools/tree/main/cfg-metadata
splunk
has already made some work on this and generate some metadata files for community exporters, extensions, processors and receivers.Moreover, here are some Go libs for generating jsonschema files based on Go types:
Thus, what are the next steps to implement this ?
I'm willing to contribute if necessary.
LBF38 commentedon Apr 24, 2024
Hi,
A temporary alternative would be to use https://github.com/dash0hq/otelbin
This tool allows to validate the otel collector config against different schemas.
And it also provides an easy way to visualise the collector flow.
See the live tool here also : https://www.otelbin.io/
jpkrohling commentedon May 8, 2024
this could be useful to the operator as well, perhaps for the auto-upgrade mechanism
cc @yuriolisa
yurishkuro commentedon May 8, 2024
@jpkrohling @TylerHelmuth I am noticing that OTEL is often not participating in LFX mentorship programs, wouldn't this be a good project for an intern?
NB: the deadline for summer term is today 5pm PT.
9 remaining items
ptodev commentedon May 16, 2024
I believe it is, because the docs need to include it.
The problem is that mapstructure doesn't have a way to set a default value through a tag.
I hope so! I'll have a look to see if I can find any.
ptodev commentedon Jun 10, 2024
@yurishkuro Unfortunately, I found it difficult to find a clean solution using protobuf. Using Pkl seems more promising to me, because it contains a lot of the features we need off the shelf. I opened #10376 to show how using Pkl in the batch processor could look like - please feel free to take a look :)
yurishkuro commentedon Jun 10, 2024
can you summarize your findings / difficulties?
ptodev commentedon Jun 11, 2024
The schema could be useful for generating code and docs both in the main Collector repo, and in its distributions. For example:
config.go
in an OTel distribution where themapstructure
tags are not sufficient.Protobuf v3 has a few notable limitations:
There are various solutions which exist to mitigate those issue individually to some extent. However, because they are all independent of each other, I don't think they would work very well together. For example, one could use protovalidate for validation, protoc-gen-doc for generating docs, and gnostic for generating schema, but since all of those are independent solutions, the validation rules won't be present in the docs and in the schema. In addition, I don't know how to work around the lack of optional arguments and default values.
On the other hand, Pkl seems pretty much designed for this use case and it is a single tool with almost everything we need right now. It was open-sourced by Apple a few months ago and is picking up popularity. Using the right tool for the job would look cleaner, be easier to maintain, and will cost less in the long term since hopefully the upstream project will maintain all those features as one cohesive whole, rather than having to rely on a set of independent products like in the Protobuf ecosystem.
theletterf commentedon Jun 19, 2024
Adding myself to the party here, after opening open-telemetry/opentelemetry-collector-contrib#24189 a year ago. +CC @atoulme.
The stake for Splunk, and for OpenTelemetry.io docs, is having reliable information in YAML format as to what metrics and configs are available for each component.
ptodev commentedon Jun 19, 2024
Hi, @theletterf! In order for you to generate docs, I suppose you need information such as:
log_level
string argument which can only have a value of either "info" or "debug". Or asend_batch_max_size_bytes
argument which has to be greater than "0".Is this a correct assumption? Do you need any other information in the schema?
theletterf commentedon Jun 19, 2024
For settings, this is the info we gather using cfgschema:
https://github.com/splunk/collector-config-tools/blob/main/cfg-metadata/exporter/otlp.yaml
For metrics:
https://github.com/splunk/collector-config-tools/blob/main/metric-metadata/elasticsearchreceiver.yaml
You might want to take a look at the contraption we built for this:
https://github.com/splunk/collector-config-tools/tree/main/cfgschema
ptodev commentedon Jun 19, 2024
Thanks, @theletterf! I will keep your requirements in mind.
I know the the Pkl PR is a bit disruptive, mostly due to the Pkl Duration type and the Pkl-specific validation rules. As a next step, I will try to propose something which doesn't disrupts the existing code so much. I may update the Pkl PR and/or revisit a solution such as the one that uses
go-jsonschema
.I can only spend about 1 day a week on this project, so it might take me a few weeks to get back to you with updated proposals.
theletterf commentedon Jun 19, 2024
Considering how long we've been chasing this, all activity is welcome. :)
tsloughter commentedon Sep 28, 2024
Right. The SDK configuration file schema is the same way but still seen as a benefit to be able to validate what it can and hope that others will extend it.
configschema
? open-telemetry/opentelemetry-collector-contrib#33778