Skip to content

autodiscovery: declarative discovery probes (KrakenD experiment)#50199

Draft
vitkyrka wants to merge 10 commits intomainfrom
vitkyrka/advanced-autoconfig-krakend
Draft

autodiscovery: declarative discovery probes (KrakenD experiment)#50199
vitkyrka wants to merge 10 commits intomainfrom
vitkyrka/advanced-autoconfig-krakend

Conversation

@vitkyrka
Copy link
Copy Markdown
Contributor

Summary

  • New file format auto_conf_discovery.yaml parsed by the file config provider (comp/core/autodiscovery/providers/config_reader.go).
  • New comp/core/autodiscovery/discovery package: OpenMetrics prober (HTTP GET + Prometheus-line verification + 30s negative cache + bounded budget).
  • New %%discovered_port%% template variable (pkg/util/tmplvar), populated via a Service wrapper after a successful probe — no configresolver.Resolve signature change.
  • AutoDiscovery's reconcile path now runs the prober before resolving any template that has a discovery: block; on no-match the check is not scheduled (logged at DEBUG).

Targets the generic-openmetrics-scan bucket from the integrations-core analysis (51/260 integrations, ~20%). Tracks Confluence ticket DSCVR/6650004331.

Companion PR with the krakend integration's auto_conf_discovery.yaml and the experiment design/plan: DataDog/integrations-core#23547

Test plan

  • dda inv test --targets=./comp/core/autodiscovery/integration,./comp/core/autodiscovery/providers,./comp/core/autodiscovery/discovery,./comp/core/autodiscovery/autodiscoveryimpl,./pkg/util/tmplvar — 442 tests pass.
  • dda inv linter.go — clean on touched packages.
  • End-to-end with krakend dev env, default port 9090: probe matched, krakend check scheduled with the discovered URL, metrics flowing.
  • End-to-end with krakend metrics on non-default port 9000: hint dropped, fallback scan found the port, check ran.
  • Negative behaviour (no candidate matches): demonstrated by initial probe attempt against a still-warming krakend container — did not match, then recovered after the 30s negative cache expired. Also unit-tested by TestProbe_AllFailReturnsFalse.

Known limitation (flagged for follow-up before any production rollout)

  • The probe runs while the configManager mutex is held — serialises service reconciliation for up to 2s per match. Acceptable for an experiment, but should move outside the lock (or async) before broadening.

🤖 Generated with Claude Code

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 30, 2026

Go Package Import Differences

Baseline: f70d80c
Comparison: 6f34723

binaryosarchchange
agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
agentaixppc64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
iot-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
iot-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
heroku-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
cluster-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
cluster-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
cluster-agent-cloudfoundrylinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery
cluster-agent-cloudfoundrylinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/comp/core/autodiscovery/discovery

@datadog-datadog-prod-us1-2

This comment has been minimized.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 30, 2026

Files inventory check summary

File checks results against ancestor f70d80cf:

Results for datadog-agent_7.80.0~devel.git.400.6f34723.pipeline.110744978-1_amd64.deb:

No change detected

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 30, 2026

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor f70d80c
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +36.12 KiB (0.00% increase) 740.757 → 740.792 → 750.310
agent_deb_amd64_fips +40.16 KiB (0.01% increase) 699.160 → 699.199 → 702.690
agent_heroku_amd64 +32.09 KiB (0.01% increase) 309.178 → 309.209 → 313.960
agent_rpm_amd64 +36.12 KiB (0.00% increase) 740.741 → 740.776 → 750.280
agent_rpm_amd64_fips +40.16 KiB (0.01% increase) 699.143 → 699.183 → 702.670
agent_rpm_arm64 +36.12 KiB (0.00% increase) 718.705 → 718.741 → 724.050
agent_rpm_arm64_fips +36.12 KiB (0.01% increase) 680.207 → 680.242 → 684.460
agent_suse_amd64 +36.12 KiB (0.00% increase) 740.741 → 740.776 → 750.280
agent_suse_amd64_fips +40.16 KiB (0.01% increase) 699.143 → 699.183 → 702.670
agent_suse_arm64 +36.12 KiB (0.00% increase) 718.705 → 718.741 → 724.050
agent_suse_arm64_fips +36.12 KiB (0.01% increase) 680.207 → 680.242 → 684.460
docker_agent_amd64 +36.12 KiB (0.00% increase) 801.141 → 801.176 → 805.870
docker_agent_arm64 +36.12 KiB (0.00% increase) 803.926 → 803.962 → 809.730
docker_agent_jmx_amd64 +36.13 KiB (0.00% increase) 992.060 → 992.096 → 996.590
docker_agent_jmx_arm64 +36.12 KiB (0.00% increase) 983.625 → 983.660 → 989.410
docker_cluster_agent_amd64 +40.12 KiB (0.02% increase) 206.539 → 206.578 → 207.600
docker_cluster_agent_arm64 +64.12 KiB (0.03% increase) 220.571 → 220.633 → 221.150
docker_dogstatsd_arm64 +64.0 KiB (0.17% increase) 37.565 → 37.627 → 38.080
dogstatsd_deb_amd64 +4.0 KiB (0.01% increase) 30.012 → 30.016 → 30.770
dogstatsd_rpm_amd64 +4.0 KiB (0.01% increase) 30.012 → 30.016 → 30.770
dogstatsd_suse_amd64 +4.0 KiB (0.01% increase) 30.012 → 30.016 → 30.770
iot_agent_deb_amd64 +32.16 KiB (0.07% increase) 44.443 → 44.474 → 44.970
iot_agent_deb_arm64 +32.09 KiB (0.08% increase) 41.423 → 41.454 → 42.560
iot_agent_deb_armhf +28.06 KiB (0.06% increase) 42.163 → 42.191 → 42.740
iot_agent_rpm_amd64 +32.16 KiB (0.07% increase) 44.443 → 44.474 → 44.970
iot_agent_suse_amd64 +32.16 KiB (0.07% increase) 44.443 → 44.474 → 44.970
4 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cws_instrumentation_amd64 7.142 MiB
docker_cws_instrumentation_arm64 6.689 MiB
docker_dogstatsd_amd64 39.358 MiB
dogstatsd_deb_arm64 28.157 MiB
On-wire sizes (compressed)
Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +7.83 KiB (0.00% increase) 175.139 → 175.147 → 179.160
agent_deb_amd64_fips +28.43 KiB (0.02% increase) 166.956 → 166.983 → 174.440
agent_heroku_amd64 +6.49 KiB (0.01% increase) 74.922 → 74.928 → 80.310
agent_rpm_amd64 +21.54 KiB (0.01% increase) 177.188 → 177.209 → 182.080
agent_rpm_amd64_fips +26.13 KiB (0.02% increase) 168.348 → 168.373 → 174.140
agent_rpm_arm64 -5.54 KiB (0.00% reduction) 159.321 → 159.315 → 163.610
agent_rpm_arm64_fips -8.88 KiB (0.01% reduction) 151.682 → 151.673 → 156.850
agent_suse_amd64 +21.54 KiB (0.01% increase) 177.188 → 177.209 → 182.080
agent_suse_amd64_fips +26.13 KiB (0.02% increase) 168.348 → 168.373 → 174.140
agent_suse_arm64 -5.54 KiB (0.00% reduction) 159.321 → 159.315 → 163.610
agent_suse_arm64_fips -8.88 KiB (0.01% reduction) 151.682 → 151.673 → 156.850
docker_agent_amd64 +46.03 KiB (0.02% increase) 267.519 → 267.564 → 272.990
docker_agent_arm64 +19.99 KiB (0.01% increase) 254.537 → 254.556 → 261.470
docker_agent_jmx_amd64 +20.45 KiB (0.01% increase) 336.184 → 336.204 → 341.610
docker_agent_jmx_arm64 +19.7 KiB (0.01% increase) 319.180 → 319.199 → 326.050
docker_cluster_agent_amd64 +8.12 KiB (0.01% increase) 72.397 → 72.405 → 73.460
docker_cluster_agent_arm64 +17.58 KiB (0.03% increase) 67.853 → 67.870 → 68.680
docker_cws_instrumentation_amd64 neutral 2.999 MiB → 3.330
docker_cws_instrumentation_arm64 neutral 2.729 MiB → 3.090
docker_dogstatsd_amd64 neutral 15.234 MiB → 15.870
docker_dogstatsd_arm64 neutral 14.551 MiB → 14.890
dogstatsd_deb_amd64 neutral 7.939 MiB → 8.830
dogstatsd_deb_arm64 neutral 6.823 MiB → 7.750
dogstatsd_rpm_amd64 neutral 7.951 MiB → 8.840
dogstatsd_suse_amd64 neutral 7.951 MiB → 8.840
iot_agent_deb_amd64 +4.18 KiB (0.03% increase) 11.697 → 11.701 → 13.210
iot_agent_deb_arm64 +12.04 KiB (0.12% increase) 9.992 → 10.004 → 11.620
iot_agent_deb_armhf +2.73 KiB (0.03% increase) 10.203 → 10.206 → 11.780
iot_agent_rpm_amd64 neutral 11.717 MiB → 13.230
iot_agent_suse_amd64 neutral 11.717 MiB → 13.230

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: def880a7-35b8-4d4d-9b97-98dd9920b233

Baseline: f70d80c
Comparison: 6f34723
Diff

Optimization Goals: ✅ No significant changes detected

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization +2.93 [-0.09, +5.95] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization +2.93 [-0.09, +5.95] 1 Logs
quality_gate_logs % cpu utilization +1.56 [+0.58, +2.54] 1 Logs bounds checks dashboard
ddot_logs memory utilization +0.77 [+0.70, +0.84] 1 Logs
otlp_ingest_metrics memory utilization +0.68 [+0.51, +0.84] 1 Logs
tcp_syslog_to_blackhole ingress throughput +0.60 [+0.40, +0.80] 1 Logs
otlp_ingest_logs memory utilization +0.35 [+0.24, +0.46] 1 Logs
ddot_metrics_sum_cumulative memory utilization +0.21 [+0.05, +0.37] 1 Logs
quality_gate_idle_all_features memory utilization +0.12 [+0.08, +0.16] 1 Logs bounds checks dashboard
file_tree memory utilization +0.07 [+0.02, +0.12] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.06 [-0.48, +0.59] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.03 [-0.38, +0.45] 1 Logs
file_to_blackhole_100ms_latency egress throughput +0.02 [-0.11, +0.15] 1 Logs
uds_dogstatsd_to_api ingress throughput +0.02 [-0.18, +0.22] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.10, +0.11] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.00 [-0.41, +0.42] 1 Logs
ddot_metrics_sum_cumulativetodelta_exporter memory utilization +0.00 [-0.24, +0.24] 1 Logs
uds_dogstatsd_to_api_v3 ingress throughput +0.00 [-0.19, +0.19] 1 Logs
ddot_metrics_sum_delta memory utilization -0.15 [-0.34, +0.04] 1 Logs
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -0.20 [-0.25, -0.15] 1 Logs
ddot_metrics memory utilization -0.30 [-0.50, -0.10] 1 Logs
quality_gate_idle memory utilization -0.47 [-0.53, -0.42] 1 Logs bounds checks dashboard
docker_containers_memory memory utilization -0.51 [-0.61, -0.41] 1 Logs
quality_gate_metrics_logs memory utilization -1.38 [-1.62, -1.14] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
docker_containers_cpu simple_check_run 10/10 698 ≥ 26
docker_containers_memory memory_usage 10/10 245.42MiB ≤ 370MiB
docker_containers_memory simple_check_run 10/10 695 ≥ 26
file_to_blackhole_0ms_latency memory_usage 10/10 0.16GiB ≤ 1.20GiB
file_to_blackhole_0ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_1000ms_latency memory_usage 10/10 0.20GiB ≤ 1.20GiB
file_to_blackhole_1000ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_100ms_latency memory_usage 10/10 0.17GiB ≤ 1.20GiB
file_to_blackhole_100ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_500ms_latency memory_usage 10/10 0.19GiB ≤ 1.20GiB
file_to_blackhole_500ms_latency missed_bytes 10/10 0B = 0B
quality_gate_idle intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 140.67MiB ≤ 147MiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 468.83MiB ≤ 495MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 3 ≤ 6 bounds checks dashboard
quality_gate_logs memory_usage 10/10 175.82MiB ≤ 195MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 350.61 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 3 ≤ 6 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 379.85MiB ≤ 430MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.

vitkyrka and others added 10 commits May 5, 2026 21:35
For the advanced auto-config experiment. New optional field on
integration.Config, populated by the auto_conf_discovery.yaml provider
in a follow-up commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Recognise the discovery: block in the file format and populate
integration.Config.Discovery. The file is picked up via the existing
.yaml extension matcher; only the configFormat struct gains a new
field and GetIntegrationConfigFromFile copies it into the returned
integration.Config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hints first (when exposed), then remaining exposed ports in declared
order. Dedup-aware.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per-(serviceID, configHash) cache. Successes never expire;
failures expire after caller-supplied TTL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
HTTP-GET each candidate port + path with a 500ms per-probe budget
and a 2s overall budget. Verify Content-Type is text/plain or
application/openmetrics-text and that the body's first non-comment
line is a Prometheus exposition line. Cache success/failure per
(serviceID, config hash).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tiny shim so %%discovered_port%% resolution can flow through the
existing GetExtraConfig path; no resolver signature change required.

Also tightens fakeService.GetExtraConfig in the prober tests to error
on unknown keys (matches the contract of real Service impls).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Routes via Resolvable.GetExtraConfig("discovered_port"). Populated by
autodiscovery/discovery's serviceWithProbeResult wrapper after a
successful probe.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a Config has Discovery set, run the OpenMetrics prober against
the matched Service before configresolver.Resolve. On match wrap the
service so %%discovered_port%% resolves; on no match skip scheduling
the check (logged at DEBUG).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SubstituteTemplateEnvVars is called at config-load time with a nil
service. Without a nil check, GetDiscoveredPort panicked on
res.GetExtraConfig. Match the pattern used by GetPort/GetPid/
GetHostname: return a NoResolverError early when res is nil so the
caller can ignore it (config_reader.go:517 already does).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Identify a non-fork PR long review PR is complex, plan time to review it team/agent-log-pipelines team/container-platform The Container Platform Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant