Skip to content

[anomalydetection] Simplify reporters (5)#52493

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
celian/refactor-correlators-reporters
Jun 26, 2026
Merged

[anomalydetection] Simplify reporters (5)#52493
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
celian/refactor-correlators-reporters

Conversation

@CelianR

@CelianR CelianR commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This moves deduplication and recurrence logic out of reporters into correlators.
Correlators now directly output events to send which is more convenient for the scorer (events like "high severity", "no more high severity")

We now have 3 types of alerts: entering high severity, leaving high severity and correlation events (new correlation / reoccurrence which is the previous type).

It basically adds a PendingEvents function to correlator to replace ActiveCorrelations (these are processed by the emitter new component).

Motivation

Describe how you validated your changes

Additional Notes

@CelianR CelianR added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests labels Jun 19, 2026
@CelianR CelianR self-assigned this Jun 19, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 40.68%
Overall Coverage: 51.01% (-0.02%)

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

@CelianR CelianR changed the title refactor(anomaly_detection): move correlation emission into correlators, clean reporters [anomalydetection] Simplify reporters Jun 19, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor f91bb03e:

Results for datadog-agent_7.82.0~devel.git.389.6b83932.pipeline.121254224-1_amd64.deb:

No change detected

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 19, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 480c61b5-6683-42ec-bcd3-16d01ae75bda

Baseline: eeaa480
Comparison: d5827b8
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_metrics_logs memory utilization +1.26 [+1.00, +1.51] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization +0.55 [+0.51, +0.59] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization +0.40 [+0.34, +0.46] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization +0.26 [+0.21, +0.32] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization +0.09 [+0.05, +0.13] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.13 [-0.22, -0.04] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -0.42 [-1.52, +0.67] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 146.66MiB ≤ 154MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 577.05KiB ≤ 819.20KiB 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 488.28MiB ≤ 495MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 0.89MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 3 ≤ 6 bounds checks dashboard
quality_gate_logs memory_usage 10/10 182.31MiB ≤ 195MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 264.20MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 342.65 ≤ 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 390.59MiB ≤ 430MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.86GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 28.57 ≤ 40 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 297.98MiB ≤ 330MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 61.04 ≤ 80 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 276.29MiB ≤ 310MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 22.18 ≤ 40 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 285.74MiB ≤ 320MiB 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".

Replicate Execution Details

We run multiple replicates for each experiment/variant. However, we allow replicates to be automatically retried if there are any failures, up to 8 times, at which point the replicate is marked dead and we are unable to run analysis for the entire experiment. We call each of these attempts at running replicates a replicate execution. This section lists all replicate executions that failed due to the target crashing or being oom killed.

Note: In the below tables we bucket failures by experiment, variant, and failure type. For each of these buckets we list out the replicate indexes that failed with an annotation signifying how many times said replicate failed with the given failure mode. In the below example the baseline variant of the experiment named experiment_with_failures had two replicates that failed by oom kills. Replicate 0, which failed 8 executions, and replicate 1 which failed 6 executions, all with the same failure mode.

Experiment Variant Replicates Failure Logs Debug Dashboard
experiment_with_failures baseline 0 (x8) 1 (x6) Oom killed Debug Dashboard

The debug dashboard links will take you to a debugging dashboard specifically designed to investigate replicate execution failures.

❌ Retried Profiling Replicate Execution Failures (ddprof)

Note: Profiling replicas may still be executing. See the debug dashboard for up to date status.

Experiment Variant Replicates Failure Debug Dashboard
quality_gate_idle_all_features baseline 10 Oom killed Debug Dashboard
quality_gate_idle_all_features comparison 10 Oom killed Debug Dashboard
quality_gate_logs comparison 10 Oom killed Debug Dashboard
quality_gate_metrics_logs baseline 10 Oom killed Debug Dashboard
quality_gate_metrics_logs comparison 10 Oom killed Debug Dashboard
quality_gate_security_no_fs_load baseline 10 Oom killed Debug Dashboard
quality_gate_security_no_fs_load comparison 10 Oom killed Debug Dashboard

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_logs, bounds check missed_bytes: 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 total_bytes_received: 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 missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

@dd-octo-sts

dd-octo-sts Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

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

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +19.34 KiB (0.00% increase, -0.18% of buffer) 747.881 → 747.899 → 758.200
agent_deb_amd64_fips +19.34 KiB (0.00% increase, -0.31% of buffer) 703.819 → 703.838 → 709.840
agent_heroku_amd64 +16.0 KiB (0.01% increase, -0.24% of buffer) 308.670 → 308.685 → 315.230
agent_rpm_amd64 +19.34 KiB (0.00% increase, -0.18% of buffer) 747.864 → 747.883 → 758.170
agent_rpm_amd64_fips +19.34 KiB (0.00% increase, -0.31% of buffer) 703.803 → 703.822 → 709.840
agent_rpm_arm64 +16.29 KiB (0.00% increase, -0.25% of buffer) 723.392 → 723.408 → 729.660
agent_rpm_arm64_fips +16.29 KiB (0.00% increase, -0.27% of buffer) 682.945 → 682.961 → 688.860
agent_suse_amd64 +19.34 KiB (0.00% increase, -0.18% of buffer) 747.864 → 747.883 → 758.170
agent_suse_amd64_fips +19.34 KiB (0.00% increase, -0.31% of buffer) 703.803 → 703.822 → 709.840
agent_suse_arm64 +16.29 KiB (0.00% increase, -0.25% of buffer) 723.392 → 723.408 → 729.660
agent_suse_arm64_fips +16.29 KiB (0.00% increase, -0.27% of buffer) 682.945 → 682.961 → 688.860
docker_agent_amd64 +19.34 KiB (0.00% increase, -0.27% of buffer) 806.699 → 806.718 → 813.790
docker_agent_arm64 +16.29 KiB (0.00% increase, -0.20% of buffer) 807.245 → 807.261 → 815.030
docker_agent_jmx_amd64 +19.35 KiB (0.00% increase, -0.27% of buffer) 997.596 → 997.615 → 1004.550
docker_agent_jmx_arm64 +16.29 KiB (0.00% increase, -0.20% of buffer) 986.796 → 986.812 → 994.710
iot_agent_deb_arm64 +4.0 KiB (0.01% increase, -0.30% of buffer) 42.406 → 42.410 → 43.720
16 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cluster_agent_amd64 208.155 MiB
docker_cluster_agent_arm64 221.377 MiB
docker_cws_instrumentation_amd64 7.447 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.028 MiB
docker_dogstatsd_arm64 37.180 MiB
docker_host_profiler_amd64 305.034 MiB
docker_host_profiler_arm64 316.119 MiB
dogstatsd_deb_amd64 29.763 MiB
dogstatsd_deb_arm64 27.818 MiB
dogstatsd_rpm_amd64 29.763 MiB
dogstatsd_suse_amd64 29.763 MiB
iot_agent_deb_amd64 45.691 MiB
iot_agent_deb_armhf 43.195 MiB
iot_agent_rpm_amd64 45.692 MiB
iot_agent_suse_amd64 45.691 MiB

@CelianR CelianR force-pushed the celian/anomalyscorer-unify branch from 583c73d to a483af0 Compare June 22, 2026 08:16
@CelianR CelianR changed the title [anomalydetection] Simplify reporters [anomalydetection] Simplify reporters (5) Jun 22, 2026
@CelianR CelianR force-pushed the celian/refactor-correlators-reporters branch from df92d4b to 1213d9c Compare June 22, 2026 12:44
@CelianR CelianR requested a review from Eokye June 22, 2026 12:53
@CelianR CelianR marked this pull request as ready for review June 22, 2026 12:54
@CelianR CelianR requested review from a team as code owners June 22, 2026 12: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: 1213d9cce0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread comp/anomalydetection/reporter/impl/reporter_event.go
@github-actions github-actions Bot added the long review PR is complex, plan time to review it label Jun 22, 2026

@Eokye Eokye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good! some comments probably have to be updated along with the one i pointed out. i like the new dedup logic! it avoids needing a TTL and other complexities

Comment thread comp/anomalydetection/AGENTS.md Outdated
@CelianR CelianR force-pushed the celian/anomalyscorer-unify branch from ccff034 to 05960f3 Compare June 26, 2026 07:24
@CelianR CelianR requested review from a team as code owners June 26, 2026 07:24
@CelianR CelianR requested a review from dustmop June 26, 2026 07:24
@CelianR CelianR force-pushed the celian/anomalyscorer-unify branch from 05960f3 to 448d6d3 Compare June 26, 2026 08:08
@CelianR CelianR force-pushed the celian/refactor-correlators-reporters branch from a6b3350 to 8fe503f Compare June 26, 2026 08:15
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Jun 26, 2026
### What does this PR do?

Unifies the anomaly scorer into a single `anomalyScorer` struct implementing the `Correlator` interface in a single file. We can now benchmark the scorer. This removes the helper reporting logs, it's merged into this struct.

This contains the main score logic and also the subscribe logic which is used to create events (high severity = event).

> [!NOTE]
> We use "the severity becomes high" and "the severity isn't high anymore" as start / end of correlation. This will be reworked in #52493 to directly emit event at the start.

The config can now enable/disable logs and reporter events (telemetry always enabled if component enabled).

New config keys for output:
```yaml
anomaly_detection:
  anomaly_scorer:
    enabled: true
    output:
      logs: true
      correlation_events: false
```

#### Diagram

```mermaid
flowchart LR
    IN["ProcessAnomaly(a)"] --> PEND["pending map"]

    PEND --> ADV

    subgraph ADV["Advance(t)  — mu held"]
        EWMA["merge → evict → bucket → EWMA"]
    end

    ADV -->|"[]secEWMA\nmu released"| SUBS

    subgraph SUBS["Per-subscription state machines  — subsMu"]
        FSM["Low / Medium / High FSM\n+ cooldown per sub"]
        FSM -->|"transition"| CB["Listener.OnSeverityTransition(evt)"]
    end

    CB -->|"self-sub\n(internal watcher)"| IW["gauges · logs · episode tracking"]

    IW --> AC["ActiveCorrelations()"]
    ADV --> SC["ScoreState() / LastScore()"]
    SUBS --> SB["Subscribe(cfg) → func()\nexposes via SubscribeScorer on Component"]
```

### Motivation

Nice score for kafka scenario, no false positives (using bocpd+tukey_biweight+holt_residual):

<img width="531" height="304" alt="Screenshot 2026-06-19 at 11 20 44" src="https://github.com/user-attachments/assets/ace05855-359a-4064-b42c-994b6baf5a1e" />

### Describe how you validated your changes

### Additional Notes

Co-authored-by: celian.raimbault <celian.raimbault@datadoghq.com>
Base automatically changed from celian/anomalyscorer-unify to main June 26, 2026 10:35
CelianR and others added 2 commits June 26, 2026 13:20
…rs, clean up reporters

Move per-pattern deduplication and CorrelationDetected emission out of the
reporter layer and into a per-correlator correlationEmitter helper. Reporters
become stateless forwarders of typed CorrelatorEvents.

Key changes:
- Add correlationEmitter helper (Observe/Drain/Reset) tracking first-seen and
  recurrence per pattern; embed in TimeClusterCorrelator and CrossSignalCorrelator
- Add CorrelatorEvent / CorrelatorEventKind to observer/def types:
  CorrelationDetected, EpisodeStarted, EpisodeEnded
- anomalyScorer: remove closedEpisodes buffer; accumulate episode lifecycle
  events via PendingEvents() drained each engine advance cycle
- engine: drain PendingEvents() from all correlators and include in ReportOutput
  as CorrelatorEvents; guard accumulation behind TrackCorrelationHistory flag
- reporter/def: ReportOutput.CorrelatorEvents replaces CorrelationHistory
- EventReporter: stateless forwarder; CorrelationDetected send failures buffered
  in retryPending (max 5 attempts) for next-cycle retry; episode events at-most-once
- stdoutReporter: emittedCounter counts only CorrelationDetected events;
  ongoingCounter fires only for active patterns not newly detected this cycle
- observer/impl/BUILD.bazel: add correlation_emitter.go and _test.go
- AGENTS.md files and reporter.allium spec updated to reflect new model

Co-authored-by: Cursor <cursoragent@cursor.com>
…AGENTS.md

Co-authored-by: Cursor <cursoragent@cursor.com>
@CelianR CelianR force-pushed the celian/refactor-correlators-reporters branch from b23788e to 6b83932 Compare June 26, 2026 11:20
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/agent-build labels Jun 26, 2026
@CelianR CelianR removed request for a team June 26, 2026 11:55
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit d5827b8 into main Jun 26, 2026
261 of 264 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the celian/refactor-correlators-reporters branch June 26, 2026 13:18
@github-actions github-actions Bot added this to the 7.82.0 milestone Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR long review PR is complex, plan time to review it qa/done QA done before merge and regressions are covered by tests team/agent-build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants