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

Clarify ScrapeConfig label selection #6453

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pavangudiwada
Copy link
Contributor

@pavangudiwada pavangudiwada commented Apr 1, 2024

Description

This PR clarifies how to configure the Prometheus Operator to select ScrapeConfigs from multiple namespaces. It also shows the field scrapeConfigNamespaceSelector.

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.

Docs clarifying ScrapeConfig label selection

@pavangudiwada pavangudiwada requested a review from a team as a code owner April 1, 2024 13:29
@@ -34,6 +34,13 @@ spec:
With this example, all `ScrapeConfig` having the `prometheus` label set to `system-monitoring-prometheus` will be used
to generate scrape configurations.

To select `ScrapeConfigs` based on the namespace `scrapeConfigNamespaceSelector` field can be used. Set it to `{}` to match `ScrapeConfigs` from all namespaces.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be also show a example with selecting based on namespace labels?

@pavangudiwada
Copy link
Contributor Author

@slashpai let me know if the following works better

  1. Changing Both the Prometheus and PrometheusAgent CRD have a scrapeConfigSelector field to Both the Prometheus and PrometheusAgent CRD have scrapeConfigNamespaceSelector and scrapeConfigSelector fields.
  2. Add example to configure both fields with labels.
  3. Another example to show them set to {} to select all selectors from all namespaces.

Question: In the context of #6404 While (3) solves the case of selecting all namespaces/objects, what does selecting none look like? Do we do something like below to add non-existing random label?

spec:
  scrapeConfigSelector:
    matchLabels:
      nolabel: non-existing-label

@@ -34,6 +34,13 @@ spec:
With this example, all `ScrapeConfig` having the `prometheus` label set to `system-monitoring-prometheus` will be used
to generate scrape configurations.

To select `ScrapeConfigs` based on the namespace `scrapeConfigNamespaceSelector` field can be used. Set it to `{}` to match `ScrapeConfigs` from all namespaces.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To select `ScrapeConfigs` based on the namespace `scrapeConfigNamespaceSelector` field can be used. Set it to `{}` to match `ScrapeConfigs` from all namespaces.
To select `ScrapeConfigs` based on the namespace, `scrapeConfigNamespaceSelector` field can be used. Set it to `{}` to match `ScrapeConfigs` from all namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants