Skip to content

Add discovery config spec tooling and krakend reference implementation#24126

Open
vitkyrka wants to merge 5 commits into
vitkyrka/disco-configfrom
vitkyrka/disco-config-tooling
Open

Add discovery config spec tooling and krakend reference implementation#24126
vitkyrka wants to merge 5 commits into
vitkyrka/disco-configfrom
vitkyrka/disco-config-tooling

Conversation

@vitkyrka

@vitkyrka vitkyrka commented Jun 22, 2026

Copy link
Copy Markdown

What does this PR do?

datadog_checks_dev — spec tooling

  • Adds discovery_validator() to spec.py: validates ad_identifiers, strategies, port_hints, and candidates; validates template placeholders against Service/Port fields
  • Extends the example consumer to generate auto_conf.yaml when a discovery section is present
  • Extends the model consumer to generate a typed discovery.py with a candidates(service: Service) function

krakend — reference implementation

  • Adds a discovery section to spec.yaml with one from_ports strategy (port_hints: [9090])
  • Generates auto_conf.yaml and discovery.py via ddev
  • Adds get_e2e_discovery_metadata() helper and dd_agent_check_discovery pytest fixture
  • Adds E2E tests, including a probe-all-configs side-effects test

The runtime infrastructure (AgentCheck.discover_config, Service, Port, probe logic) is in #23963.

Motivation

https://datadoghq.atlassian.net/browse/DSCVR-482
https://datadoghq.atlassian.net/wiki/spaces/DSCVR/pages/6671862234/#Integrations-Core

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • 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

vitkyrka commented Jun 22, 2026

Copy link
Copy Markdown
Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 22, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 2 Pipeline jobs failed

PR All | test / j06ca546 / SNMP   View in Datadog   GitHub Actions

PR | test / check   View in Datadog   GitHub Actions

🧪 1 Test failed in 1 job

PR All | run   GitHub Actions

All test failures are known flaky — job may pass on retry.

❄️ Known flaky: test_e2e_snmp_listener from test_e2e_snmp_listener.py   View in Datadog
Needed at least 1 candidates for &#39;datadog.snmp.check_duration&#39;, got 0
Expected:
        MetricStub(name=&#39;datadog.snmp.check_duration&#39;, type=0, value=None, tags=[&#39;autodiscovery_subnet:172.18.0.0/28&#39;, &#39;device_vendor:apc&#39;, &#39;firmware_version:2.0.3-test&#39;, &#39;loader:python&#39;, &#39;model:APC Smart-UPS 600&#39;, &#39;serial_num:test_serial&#39;, &#39;snmp_device:172.18.0.1&#39;, &#39;snmp_profile:apc_ups&#39;, &#39;ups_name:testIdentName&#39;], hostname=None, device=None, flush_first_value=None)
Difference to closest:
        Expected tag snmp_device:172.18.0.1
        Found snmp_device:172.18.0.2

Similar submitted:
Score   Most similar
1.00    MetricStub(name=&#39;datadog.snmp.check_duration&#39;, type=0, value=0.18406128883361816, tags=[&#39;autodiscovery_subnet:172.18.0.0/28&#39;, &#39;device_vendor:apc&#39;, &#39;firmware_version:2.0.3-test&#39;, &#39;loader:python&#39;, &#39;model:APC Smart-UPS 600&#39;, &#39;serial_num:test_serial&#39;, &#39;snmp_device:172.18.0.2&#39;, &#39;snmp_profile:apc_ups&#39;, &#39;ups_name:testIdentName&#39;], hostname=&#39;runnervm08nci&#39;, device=None, flush_first_value=False)
...

Not introduced in this PR.

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 75.19%
Overall Coverage: 87.96% (-0.08%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0eb0b05 | Docs | Datadog PR Page | Give us feedback!

@vitkyrka vitkyrka added the qa/skip-qa Automatically skip this PR for the next QA label Jun 22, 2026
@vitkyrka vitkyrka force-pushed the vitkyrka/disco-config-tooling branch from 48fb4d7 to 247fee6 Compare June 22, 2026 12:52
@vitkyrka vitkyrka force-pushed the vitkyrka/disco-config branch from 93d8da4 to 15901ae Compare June 22, 2026 12:52
@vitkyrka vitkyrka changed the title Add discovery config spec validation and model generation to ddev. Add discovery config spec validation and model generation to ddev Jun 22, 2026
@vitkyrka vitkyrka force-pushed the vitkyrka/disco-config branch from 15901ae to a2403a4 Compare June 22, 2026 13:35
@vitkyrka vitkyrka force-pushed the vitkyrka/disco-config-tooling branch from 247fee6 to b447ffe Compare June 22, 2026 13:35
@vitkyrka vitkyrka marked this pull request as ready for review June 22, 2026 13:54
@vitkyrka vitkyrka requested a review from a team as a code owner June 22, 2026 13:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b447ffec92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

vitkyrka and others added 5 commits June 23, 2026 13:04
Adds a discovery section to the spec schema (port_hints, strategy field),
extends the example and model consumers to render/generate discovery config,
adds spec.py validation for discovery spec correctness, and covers the new
paths with tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds krakend config_models/discovery.py and auto_conf.yaml for port-based
config autodiscovery. Adds get_e2e_discovery_metadata() to ddev docker helpers
and a dd_agent_check_discovery pytest fixture so integrations can run
discovery-path E2E tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… on server

To ensure that this no risk with probing the ports of the container for
configuration discovery, add a test which instanciates the integration which
each of the generated configurations in turn and checks that the container logs
don't have any obvious crashes.

 https://datadoghq.atlassian.net/wiki/spaces/DSCVR/pages/6671862234/Configuration+Discovery+for+Agent+Integrations#Probing-causes-problems

While the logic for detecting "bad" effects is best-effort, the test also the
logs from this scenario to be seen easier during development.

For example, for krakend:

```
$ ddev env test --base --new-env krakend py3.13-2.10 -- -k test_e2e_discovery_candidates_do_not_destabilize_container -rP --log-level=DEBUG
...
_________ test_e2e_discovery_candidates_do_not_destabilize_container __________
------------------------------ Captured log call -------------------------------
DEBUG    root:docker.py:90 Probing candidate #1: {'init_config': {}, 'instances': [{'openmetrics_endpoint': 'http://172.17.129.3:9090/metrics'}]}
DEBUG    root:docker.py:90 Probing candidate #2: {'init_config': {}, 'instances': [{'openmetrics_endpoint': 'http://172.17.129.3:8080/metrics'}]}
DEBUG    root:docker.py:94 Error probing candidate #2: {'init_config': {}, 'instances': [{'openmetrics_endpoint': 'http://172.17.129.3:8080/metrics'}]}
DEBUG    root:docker.py:103 New log line: [GIN] 2026/06/17 - 15:31:46 | 404 |       2.803µs |    172.17.129.1 | GET      "/metrics"
DEBUG    root:docker.py:103 New log line: [GIN] 2026/06/17 - 15:31:47 | 404 |       2.753µs |    172.17.129.1 | GET      "/metrics"
DEBUG    root:docker.py:90 Probing candidate #3: {'init_config': {}, 'instances': [{'openmetrics_endpoint': 'http://172.17.129.3:8090/metrics'}]}
DEBUG    root:docker.py:94 Error probing candidate #3: {'init_config': {}, 'instances': [{'openmetrics_endpoint': 'http://172.17.129.3:8090/metrics'}]}
DEBUG    root:docker.py:103 New log line: [GIN] 2026/06/17 - 15:31:49 | 200 |      51.868µs |             ::1 | GET      "/__health"
```
@vitkyrka vitkyrka force-pushed the vitkyrka/disco-config-tooling branch from 3430189 to 0eb0b05 Compare June 23, 2026 13:25
@vitkyrka vitkyrka requested review from a team as code owners June 23, 2026 13:25
@vitkyrka vitkyrka changed the title Add discovery config spec validation and model generation to ddev Add discovery config spec tooling and krakend reference implementation Jun 23, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

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.

2 participants