-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cmd/mdatagen] Ability to filter by resource attribute values #25134
Comments
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
For the include/exclude config interface, we need to stick to the new standardized approach proposed in #25161. People are more in favor of option B, but we still have time to reconsider it. |
👋 Have a very raw draft PR for this functionality, would love to get some reviews if this is the approach we would like to take. Basically it implements this kind of interface:
NewResourceBuilder will need to now return an error, since it needs to compile the regexes.
We still have the open question around what do we do with types such as int, double, bool, bytes, slice and map? ATM we generate only for string setters cc @dmitryax |
I think those should only accept |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
…9660) **Description:** This PR allows filtering out metrics based on resource attributes. For example: ``` resource_attributes: k8s.pod.name: enabled: true exclude: #- strict: "kube-apiserver-kind-control-plane" - regexp: "kube-.*" - regexp: "coredns-.*" - strict: "coredns" - strict: "kindnet-mpb2p" ``` Would remove metrics that match regex or strict rules on resource attributes. **Link to tracking Issue:** open-telemetry/opentelemetry-collector-contrib#25134 **Testing:** - Tested with k8scluster receiver in kind cluster. - unit tests added **Documentation:** <Describe the documentation added.> --------- Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
I have two problems with this approach:
I believe the right solution to this is to use OTTL, as we're dealing with filtering/transforming telemetry here (metrics specifically) and OTTL was specifically designed for these scenarios. Given the currently implemented solution in #9660 and #9960, here's the closest I could get to achieving the requester's goal from this comment: Goal: Only emit the following process metrics:
receivers:
hostmetrics:
scrapers:
process:
resource_attributes:
process.executable.name:
metrics_include:
- strict: otel-collector
- strict: collector2
process.command_line:
metrics_exclude:
- regexp: ^test Note that with this syntax it's not possible to satisfy the requester's goal fully. It's not possible to also allow the "java"/"minecraft" metrics. Here's what a configuration based on OTTL would look like (this is similar to how Filter processor would be configured): receivers:
hostmetrics:
scrapers:
process:
metrics:
filters:
resource:
- 'IsMatch(attributes["process.command_line"], "^test") or !IsMatch(attributes["process.executable.name"], "^otel-collector$|^collector2$")'
- 'attributes["process.command"] != "java" or attributes["process.command_line"] == "minecraft"'
Actually I believe this is still hard to read, write and understand due the user needing to negate the exclusion logic to achieve an inclusion logic. I propose to allow the user to specify either an inclusion filter or an exclusion filter (or maybe both, with exclusion applied after inclusion). Here's what it would look like: receivers:
hostmetrics:
scrapers:
process:
metrics:
include[_filters]:
resource:
- '(attributes["process.executable.name"] == "otel-collector" or attributes["process.executable.name"] == "collector2") and !IsMatch(attributes["process.command_line"], "^test")'
- 'attributes["process.command"] == "java" and attributes["process.command_line"] == "minecraft"' Ideally we should be able to extend this OTTL postprocessing of telemetry to other signals than metrics - logs, traces at al. But this issue is only about metrics, so I propose to put it in |
The `include` and `exclude ` options in the resource attributes group sound confusing. It's easy to assume that matching filters will include or exclude resource attributes themselves while they control emitted resource metrics. The proposal is to change the include/exclude options to `metrics_include`/`metrics_exclude` with detailed comments. These names make it cleaner that matching rules limit the emitted metrics, not resource attributes. Updates open-telemetry/opentelemetry-collector-contrib#25134
@andrzej-stencel I understand that some complicated use cases might not be covered by this interface. And I don't think we need to aim for that. Any complicated use case can be solved by adding the filter processor. The intent behind this issue is to provide a simple interface to control what resources are "allowed" to emit metrics. It'll be a pretty important feature for scraping receivers collecting data with many resources. For example, in the k8scluster receiver, if I want to simply exclude all metrics from the
which seems pretty straight-forward to use compared to
I see two problems with the approach you suggest:
|
@povilasv I'd like to hear your input here and what's your use case |
I basically agree with everything you @dmitryax said. I think OTTL option was discussed in #25161 and Sig meeting (if I recall correctly). The use case here is basically simple way to filter data, similiar to what we have in hostmetric processor but just for mdatagen receivers. This approach we took IMO solves it and it is applied broadly. Do you want to monitor just x namespace, you can do it, just y Mongo / redis / .. instance, you can do it. |
BTW I think we can close this ticket as done. Any changes in interface we should probably discuss in #25161 |
The `include` and `exclude ` options in the resource attributes group sound confusing. It's easy to assume that matching filters will include or exclude resource attributes themselves while they control emitted resource metrics. The proposal is to change the include/exclude options to `metrics_include`/`metrics_exclude` with detailed comments. These names make it cleaner that matching rules limit the emitted metrics, not resource attributes. Updates open-telemetry/opentelemetry-collector-contrib#25134
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping |
This issue has been closed as inactive because it has been stale for 120 days with no activity. |
There are some scenarios when scrapers emit metrics for too many different resource attributes. We need to introduce a configuration interface generated and applied to every item in
resource_attributes
section that users can use to reduce the set of emitted resource attribute metrics.We already have an option to disable resource attributes like this:
We can add an option to filter resource metrics in the same configuration section.
So user can do the following:
The exact filtering interface is still to be defined.
Originally suggested in #8188 (comment)
The text was updated successfully, but these errors were encountered: