Skip to content
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

[mdatagen] allow filtering out metrics based on resource attributes #29769

Closed
wants to merge 1 commit into from

Conversation

povilasv
Copy link
Contributor

@povilasv povilasv commented Dec 12, 2023

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:

#25134
Testing:

  • Tested with k8scluster receiver in kind cluster.
  • unit tests added
    Documentation:

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 27, 2023
@dmitryax dmitryax removed the Stale label Jan 2, 2024
cmd/mdatagen/templates/resource.go.tmpl Outdated Show resolved Hide resolved
cmd/mdatagen/templates/resource.go.tmpl Outdated Show resolved Hide resolved
cmd/mdatagen/validate.go Outdated Show resolved Hide resolved
internal/filter/filter/config.go Outdated Show resolved Hide resolved
@dmitryax
Copy link
Member

dmitryax commented Jan 2, 2024

Good start. Thanks @povilasv!

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@povilasv
Copy link
Contributor Author

Tested validation with:

        resource_attributes:                                                                      
          k8s.pod.name:
            enabled: true 
            include:
              - regexp: ".*"
              - regexp: "(["
            exclude:
              - strict: "kube-apiserver-kind-control-plane"

Collector fails with:

2024/01/24 12:49:46 collector server run finished with error: invalid configuration: receivers::k8s_cluster: error parsing regexp: missing closing ]: `[`

So looks like the engine magically calls Validate() on the config 👍

@povilasv povilasv force-pushed the mdatagen-filter branch 2 times, most recently from e5e3078 to 2668ba5 Compare January 24, 2024 13:15
@povilasv povilasv force-pushed the mdatagen-filter branch 3 times, most recently from 84995e1 to b8f9a6d Compare January 25, 2024 12:52
@povilasv
Copy link
Contributor Author

Thanks for reviewing @dmitryax , this is ready for the second round :)

I played with this change in a kind cluster, and looks it does what we want :D

@fatsheep9146
Copy link
Contributor

fatsheep9146 commented Jan 30, 2024

I think metadata-schema.yaml could also be updated to include this changes.

@povilasv
Copy link
Contributor Author

povilasv commented Jan 31, 2024

I don't think we need to change metadata-schema.yaml , as this change allows end-user to configure filtering. There is no change in metadata schema for receiver maintainers.

@povilasv povilasv force-pushed the mdatagen-filter branch 2 times, most recently from 74b6f9b to 04733d9 Compare January 31, 2024 13:22
@povilasv povilasv force-pushed the mdatagen-filter branch 2 times, most recently from 0d7b9ec to 5f895a2 Compare February 9, 2024 09:38
@povilasv povilasv mentioned this pull request Feb 12, 2024
4 tasks
internal/filter/filter/config.go Outdated Show resolved Hide resolved
internal/filter/filter/config.go Outdated Show resolved Hide resolved
receiver/apachesparkreceiver/go.mod Show resolved Hide resolved
receiver/couchdbreceiver/go.mod Show resolved Hide resolved
@povilasv povilasv force-pushed the mdatagen-filter branch 3 times, most recently from 188da45 to a1f6e1a Compare February 15, 2024 12:24
@povilasv
Copy link
Contributor Author

@dmitryax Thanks for review! Updated based on your comments :)

@povilasv povilasv force-pushed the mdatagen-filter branch 2 times, most recently from 0fd59fe to 38b06f9 Compare February 21, 2024 10:41
@dmitryax
Copy link
Member

@povilasv PTAL at the failing CI

@dmitryax
Copy link
Member

@povilasv the PR looks good to me in general. Can you please submit if against mdatagen in core?

@povilasv
Copy link
Contributor Author

Pushed a PR for core open-telemetry/opentelemetry-collector#9660

@povilasv
Copy link
Contributor Author

povilasv commented Mar 4, 2024

Closing this PR, as I added more tests and different packaging for the new filter package in the core repository. PR: open-telemetry/opentelemetry-collector#9660

I think we can review / merge the functionality after we fully deprecate the mdatagen in contrib.

@povilasv povilasv closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants