Add container-based config discovery support for haproxy - #24572
Merged
Conversation
Enables Autodiscovery to generate the OpenMetrics V2 instance config (port 8404, /metrics) from a discovered haproxy container's exposed ports. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: b7aed48 | Docs | Datadog PR Page | Give us feedback! |
evazorro
approved these changes
Jul 17, 2026
sarah-witt
approved these changes
Jul 17, 2026
Contributor
Validation ReportAll 21 validations passed. Show details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a container-based config discovery block for the
haproxyintegration, so Autodiscovery can generate a working instance config from a discovered haproxy container without manual setup.assets/configuration/spec.yaml: adds afrom_portsdiscovery strategy targeting port8404(HAProxy's own documented Prometheus-exporter convention — see haproxy.com's Prometheus exporter tutorial), generating an instance withuse_openmetrics: "true"andopenmetrics_endpointset. The manualfrom_portsform (rather than theopenmetrics_from_portstemplate) is required because the check's__new__dispatch needs theuse_openmetricsflag alongside the endpoint, not just the endpoint.auto_conf.yamlfiles-entry (ad_identifiers: [haproxy]) so the config is picked up by name.config_models/discovery.py,discovery_overrides.py,discovery_strategies.py, anddata/auto_conf.yamlviaddev -x validate config/models -s haproxy.tests/conftest.py'sdd_environmentfixture withget_e2e_discovery_metadata()so the E2E Agent container can read the target container's labels/ports.test_e2e_discovery(validates real metric collection through a fully-discovered instance) andtest_e2e_discovery_all_candidates(validates every generated candidate against the live container without crashing it) totests/test_e2e.py.datadog-checks-basefloor to37.41.0for the discovery framework APIs used above.Scope and limitations
This PR intentionally supports only HAProxy containers exposing the Prometheus exporter on port
8404with the conventional/metricspath.Legacy stats-page mode is not auto-discovered because it can require operator-provided credentials and a deployment-specific stats URL, which cannot be safely synthesized by Autodiscovery.
Deployments exposing the Prometheus exporter on a different path will still need manual configuration.
Motivation
Part of the Discovery team's broader Autodiscovery rollout across integrations-core checks (DSCVR-515).
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged