Skip to content

fix anomaly dimension baselines#22

Merged
crypticani merged 1 commit into
mainfrom
fix/anomaly-dimension-baselines
Jun 7, 2026
Merged

fix anomaly dimension baselines#22
crypticani merged 1 commit into
mainfrom
fix/anomaly-dimension-baselines

Conversation

@crypticani

Copy link
Copy Markdown
Owner

Summary

  • correct anomaly baselines so rows are grouped by account/tenancy, compartment, service, region, and currency
  • calculate baselines from matching spend in the previous 7 completed calendar days instead of a mixed row window
  • add migration 014_anomaly_dimensions.sql for compartment, currency, and direction fields
  • make provider, compartment, region, service, and scope filters apply to anomaly results
  • add Compartment, Currency, and Direction to the anomaly tables
  • color increases red and decreases green while keeping severity as a neutral magnitude
  • enforce an explicit Grafana column order

Root cause

The previous window partition omitted compartment, record type, and currency, and used a row-count window. Multiple daily summary rows could therefore be treated as prior days for an unrelated row, producing misleading 7-day averages. The anomaly endpoint also ignored the OCI dashboard dimension filters.

Migration

Migration 014_anomaly_dimensions.sql changes only the derived cost_anomalies table. It does not delete raw cost records or summary data. Existing anomaly rows are cleared because their missing dimensions and mixed baselines cannot be reconstructed safely. They are regenerated during the next dashboard analytics refresh.

Validation

  • go test ./...
  • go build ./cmd/... ./internal/...
  • focused PostgreSQL/TimescaleDB integration test with two same-service compartments
  • make compose-dev-config
  • make compose-prod-config
  • dashboard and Swagger JSON validation
  • git diff --check origin/main...HEAD
  • verified both provisioned dashboard models through the running Grafana API

Follow-up to #21.

@crypticani crypticani merged commit 4b9a558 into main Jun 7, 2026
5 checks passed
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