Skip to content

feat(insights): OpenSearch AD and Elasticsearch ML anomaly pipeline#30

Open
kgrubb wants to merge 5 commits into
mainfrom
feat/insights-native-anomaly-detection
Open

feat(insights): OpenSearch AD and Elasticsearch ML anomaly pipeline#30
kgrubb wants to merge 5 commits into
mainfrom
feat/insights-native-anomaly-detection

Conversation

@kgrubb
Copy link
Copy Markdown
Contributor

@kgrubb kgrubb commented May 14, 2026

Added

  • Proactive insight polling can surface OpenSearch Anomaly Detection and Elasticsearch ML anomalies on the same path as alerting (dedupe, severity gate, LLM, postInsight).
  • Idempotent discover → adopt → seed for egress-shaped detectors/jobs using existing search config and resolved field mapping, without new environment variables.
  • elasticsearch_ml_anomaly finding kind; enrichment for opensearch_anomaly and elasticsearch_ml_anomaly when contributing source IPs are present.

Changed

  • After field mapping, the engine ensures the native anomaly pipeline once per run and keeps an ES ML client when the backend is Elasticsearch.
  • OpenSearch AD queries prefer the Kaytoo result index pattern and filter by adopted detector ids when available.
  • Heuristic egress is skipped on a poll only when the native pipeline is healthy and native fetches report healthyEmpty (so heuristics are not silenced when AD/ML is unavailable).

Fixed

  • String JSON search bodies are handled for shard counts and hits via parseJsonOrNull, consistent with the rest of the codebase.

kgrubb added 5 commits May 13, 2026 22:54
## Added
- Idempotent OpenSearch AD discover/adopt/seed via transport and scoped
  anomaly result queries.
- Elasticsearch ML job, datafeed, and `getRecords`-backed findings.
- `elasticsearch_ml_anomaly` finding kind and enrichment when source IPs
  are present.

## Changed
- Insight engine ensures the native pipeline after field mapping; polls
  OS or ES for anomalies and alerts on the existing path.
- Heuristic egress polling skips only when native pipeline is healthy and
  native fetches report a healthy empty window.
- OpenSearch AD/alerting searches accept string JSON bodies using shared
  `parseJsonOrNull` (shard counts and hits stay consistent).

## Fixed
- Heuristics no longer stay suppressed when native anomaly setup is not
  actually ready.
…logs)

## Changed
- Detect ML `resource_already_exists` via `meta.body.error.type` and
  `body.error.type` when present, with string fallback for older clients.
- Normalize ML record `timestamp` from epoch ms or ISO strings for stable
  finding ids and windows.
- Log throttled JSON parse warnings for OpenSearch shard counts when the
  search body is a malformed string (same as hits path).
- Debug log when multiple egress-shaped AD detectors or ML jobs match so
  operators see deterministic single adoption.

## Fixed
- Heuristic feature match comment clarifies JSON substring check is not a
  full aggregation AST.
## Changed
- ML pipeline: extract create helper; derive jobIds without reassignment.
- OpenSearch AD: extract egressDetectorIdsEnsure; single const detectorIds.
- Insight engine: resolve native anomaly context via async IIFE; poll
  timer/inFlight held in one const object.
- ML job tie-break: sort a copy of matches instead of mutating the array.
## Changed
- Numeric ML record timestamps: assume ms from API; if value is below 1e12,
  treat as epoch seconds before converting to ISO.

## Fixed
- OpenSearch AD relist failure path: assert three transport calls for empty
  relist; add case where relist returns hits that fail egress match.
…logs

## Added
- verify: second AD list call requires Kaytoo egress detector name in JSON
  (confirms native seed/adopt against OpenSearch).
- verify: optional log line when Anomaly appears (graded AD in console path).

## Changed
- e2e README: document the new native AD assertion and optional Anomaly hint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant