Commit c9150d5
[Backport 7.82.x] autodiscovery: skip config discovery when a generic openmetrics/prometheus config already exists (#54270)
Backport 75b1f56 from #54263.
___
## What does this PR do?
Config discovery currently only skips proposing a discovered integration's check when another config *for the same integration name* already covers the service or host. In practice, many customers point the generic `openmetrics`/`prometheus` checks at a service instead of using the specific integration. Discovery doesn't recognize this as a conflict (different `Name`), so it still proposes the specific integration's check alongside the generic one, which can lead to duplicate — and for counters, doubled — metrics.
This implements the "quickest fix" option from [Config discovery conflict with generic integrations](https://datadoghq.atlassian.net/wiki/spaces/DSCVR/pages/7031522288/Config+discovery+conflict+with+generic+integrations): if an `openmetrics` or `prometheus` config already matches the service, or is scheduled host-wide, skip config discovery for *every* integration on that service/host, regardless of `Name`.
## Motivation
Avoid duplicate/doubled metrics when a generic `openmetrics`/`prometheus` config already covers the same service that config discovery would otherwise also configure via a specific integration.
https://datadoghq.atlassian.net/browse/DSCVR-626
## Describe how to test/verify your changes
Added unit tests in `comp/core/autodiscovery/listeners/service_test.go` (`TestServiceFilterTemplatesDiscovery`) covering:
- a discovery template is dropped when an `openmetrics` sibling config matches the same service, even though it has a different `Name`
- a discovery template is dropped when `prometheus` is configured host-wide (in the static config index)
- an unrelated discovery template on the same service/host is also dropped, since a generic integration match is treated as covering every integration
## Possible Drawbacks / Trade-offs
This can cause false-positive skips: e.g. if a generic `openmetrics`/`prometheus` config targets one container/host but doesn't actually scrape the same metrics as the discoverable integration, or targets a different service, discovery will still be skipped. See the wiki page for the full discussion of alternatives that reduce this risk at the cost of being slower to ship.
Co-authored-by: ali.benabdallah <ali.benabdallah@datadoghq.com>1 parent 035c4cf commit c9150d5
2 files changed
Lines changed: 68 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
| |||
44 | 56 | | |
45 | 57 | | |
46 | 58 | | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
50 | 73 | | |
51 | 74 | | |
52 | 75 | | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
56 | 79 | | |
57 | | - | |
| 80 | + | |
58 | 81 | | |
59 | 82 | | |
60 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
197 | 204 | | |
198 | 205 | | |
199 | 206 | | |
| |||
268 | 275 | | |
269 | 276 | | |
270 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
271 | 314 | | |
272 | 315 | | |
273 | 316 | | |
| |||
0 commit comments