Skip to content

Conversation

zhuminyi
Copy link
Contributor

@zhuminyi zhuminyi commented Aug 27, 2025

What does this PR do?

This PR adds support for the openmetrics_endpoint configuration field in the kube_scheduler, making them compatible with deployments that use this field name instead of prometheus_url.

Motivation

clusters using openmetrics_endpoint for kube_scheduler check are experiencing initialization failures with error message:

Error: {
  "Core Check Loader": "Check kube_scheduler not found in Catalog",
  "Python Check Loader": "could not configure check instance for python check kube_scheduler: could not invoke 'kube_scheduler' python check constructor. New constructor API returned:\nTraceback (most recent call last):\n  File 
  ...
  datadog_checks.base.errors.CheckException: Unable to find prometheus URL in config file.\nDeprecated constructor API returned:\nKubeSchedulerCheck.__init__() got an unexpected keyword argument 'agentConfig'"
}
Screenshot 2025-08-27 at 2 07 25 AM

Investigation showed that clusters are using pod annotations with openmetrics_endpoint field:

  {
    "kube_scheduler": {
      "instances": [{
        "openmetrics_endpoint": "https://%%host%%:10251/metrics",  
      }]
    }
  }

This PR implement OpenMetrics v2 support using the dual-mode pattern:

  1. If only openmetrics_endpoint is provided, it's mapped to prometheus_url
  2. If only prometheus_url is provided, it works as before
  3. If neither field is provided, a clear error is raised
  4. Both field names are accepted for maximum compatibility

With this priority setup:
New users see openmetrics_endpoint first (Priority 1) in documentation/examples
Existing users can continue using prometheus_url without changes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.96%. Comparing base (642a5e8) to head (cdcb1f3).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhuminyi zhuminyi force-pushed the OPMv2_kube_scheduler branch 2 times, most recently from 4e1d1af to 482071f Compare August 27, 2025 06:06
@zhuminyi zhuminyi changed the title Support openmetrics_endpoint in kube_scheduler check [CONTP-947] Support openmetrics_endpoint in kube_scheduler check Aug 27, 2025
@zhuminyi zhuminyi force-pushed the OPMv2_kube_scheduler branch 2 times, most recently from 6237f62 to b5f824f Compare August 27, 2025 06:25
@zhuminyi zhuminyi requested a review from a team as a code owner August 27, 2025 06:25
@datadog-agent-integrations-bot datadog-agent-integrations-bot bot added qa/skip-qa Automatically skip this PR for the next QA labels Aug 27, 2025
@zhuminyi zhuminyi force-pushed the OPMv2_kube_scheduler branch from b5f824f to 38995a0 Compare August 27, 2025 06:27
Copy link

⚠️ The qa/skip-qa label has been added with shippable changes

The following files, which will be shipped with the agent, were modified in this PR and
the qa/skip-qa label has been added.

You can ignore this if you are sure the changes in this PR do not require QA. Otherwise, consider removing the label.

List of modified files that will be shipped with the agent
kube_scheduler/datadog_checks/kube_scheduler/config_models/defaults.py
kube_scheduler/datadog_checks/kube_scheduler/config_models/instance.py
kube_scheduler/datadog_checks/kube_scheduler/config_models/validators.py
kube_scheduler/datadog_checks/kube_scheduler/data/conf.yaml.example

@zhuminyi zhuminyi force-pushed the OPMv2_kube_scheduler branch from 38995a0 to cdcb1f3 Compare August 27, 2025 06:31
Copy link

⚠️ The qa/skip-qa label has been added with shippable changes

The following files, which will be shipped with the agent, were modified in this PR and
the qa/skip-qa label has been added.

You can ignore this if you are sure the changes in this PR do not require QA. Otherwise, consider removing the label.

List of modified files that will be shipped with the agent
kube_scheduler/changelog.d/21178.added
kube_scheduler/datadog_checks/kube_scheduler/config_models/defaults.py
kube_scheduler/datadog_checks/kube_scheduler/config_models/instance.py
kube_scheduler/datadog_checks/kube_scheduler/config_models/validators.py
kube_scheduler/datadog_checks/kube_scheduler/data/conf.yaml.example

@zhuminyi zhuminyi closed this Aug 27, 2025
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.

1 participant