Skip to content

feat(observability): alert on pending pods and oldest queued jobs (#1050) - #1051

Merged
athvin merged 4 commits into
mainfrom
issue/1050-operational-age-alarms
Nov 9, 2026
Merged

athvin merged 4 commits into
mainfrom
issue/1050-operational-age-alarms

Conversation

@athvin

@athvin athvin commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1050

🚧 Claimed by an agent session — 2026-11-09T12:59:57Z, session Codex:01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac-28.lan.
The claim is this open draft PR: closing it releases the ticket.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Page on Pending runner pods older than 600 seconds and queued jobs older than 900 seconds, with current-state gauges and independent observation health.

Why

#667 explicitly separates these alerts from its externally blocked cost model. Existing queue-depth and transition metrics cannot detect one old waiting job or a silent pod observation path.

Proof

Focused age/failure units, metric export/reset tests, a real-Postgres operational projection test, entity verification, Terraform validation and its mock-provider contract test passed. Deliberately changing the pending threshold made that contract fail. make check passed on final commit ee1f7f37. Full make check-e2e passed before the trace-only follow-up, including real Postgres and DuckLake/extensions; the focused pod-observation tests passed again after it. Independent SQL, tier and reuse reviews found no issues. One instrumentation finding was confirmed, fixed and independently verified.

Risk & rollback

The existing dispatcher adds a bounded managed-object observation alongside its periodic database sample; failed observations retain the last gauge and stop the independent heartbeat. Dev alarms are added through the existing module; prod collector wiring remains #944. Revert the merge to roll back.

Post-merge ledger

Closed by: Codex · session 01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac-28.lan · 2026-11-09T14:25:33.666470+00:00

Specific to this change

  • Terraform apply — infra 42629666008 applied dev with 3 added, 1 changed and 0 destroyed at 13:58:13Z. Core and prod each reported 0/0/0.
  • Independent metric/alarms readback — er-readonly CloudWatch queries on 2026-11-09 found real ER/Dev and ER/Prod samples (dimension OTelLib=er-obs) for er.ops.snapshots and er.pods.snapshots, two samples/minute at 15:07–15:08Z, plus queue/pending oldest-age gauges at zero seconds. All seven operational alarms in both environments read OK during the 15:12–15:13Z audit. The prior read-access limitation is resolved.
  • SNS delivery — blocked — er-alerts still has a PendingConfirmation email subscription. Owner confirmation and receipt verification are tracked in Confirm the er-alerts email subscription and prove alert delivery #1056; alarm state alone does not prove delivery.
Context — plan, discoveries, measurements, files

Plan

  1. Extend the existing declared job/read/operational_queue projection with the oldest queued creation timestamp; regenerate entity artifacts, retain backoff jobs, and derive a zero-on-empty age alongside the current queue sample.
  2. Carry the Kubernetes creation timestamp in PodSnapshot. Reuse the executor's namespace-scoped PodApi and managed selector for a bounded periodic LIST; derive the maximum age of actual Pending pods. A missing required timestamp or failed/timeout LIST produces no success sample. No new watcher, RBAC, cloud credential, or retry machinery.
  3. Add bounded queue-age and pending-age gauges plus an independent pod-snapshot heartbeat in er-obs. Keep the existing database heartbeat independent so a Kubernetes outage does not erase queue visibility. Emit zeros on healthy empty snapshots and regenerate the metric reference.
  4. Extend the existing operational dashboard/module with the 900 s queue-age and 600 s pending-age alerts, and a missing pod-snapshot alert needed to distinguish silence from idle. Reuse the existing SNS topic and actual OTelLib dimension. The current module instantiation is dev; prod observability remains Prod observability install: span-store topology decision + prod shipper values #944.
  5. Prove real Postgres age aggregation/exclusion/backoff behavior, Kubernetes timestamp/phase handling, zero reset, failed reads, and metric export dimensions; assert Terraform alarm thresholds/actions/missing-data semantics with its mock provider. Run make check, make check-e2e, entity/metric generation checks and credential-free Terraform validation/tests.
  6. Update the operational runbook, complete house review and exact-head CI, land and watch main/deploy/apply. SQL, tier and reuse reviews found no issues; instrumentation review identified missing error trace status, independently confirmed and corrected using the existing span helpers. The correction is independently verified and its final make check passed on ee1f7f37; exact-head CI and the 30-minute merge watch passed. Preserve blocked independent live readback honestly in the post-merge ledger.

Discoveries

PodSnapshot lacked Kubernetes creation time, so local observation clocks would reset on dispatcher restart. The projection now carries the platform timestamp. Database and pod observations use independent heartbeats so an API outage cannot manufacture an empty/healthy pod chart or erase queue visibility. No account mutation was performed locally.

Measurements

Files

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

4820da1 · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 3 1 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

dev — 3 to add, 1 to change
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_iam_policy_document.efs_csi_trust: Reading...
module.network.data.aws_region.current: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.eso: Read complete after 0s [id=1725605485]
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
data.aws_region.current: Reading...
data.aws_iam_policy_document.er_api_pod_trust: Reading...
module.network.data.aws_availability_zones.available: Reading...
data.aws_iam_policy_document.er_api_pod_trust: Read complete after 0s [id=819195744]
data.aws_region.current: Read complete after 0s [id=us-east-2]
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_iam_policy_document.obs_pod_trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.otel_collector: Reading...
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=3111493560]
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=4006586444]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
module.lake.data.aws_iam_policy_document.lake_tls_only: Read complete after 0s [id=2205495074]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=2921565705]
data.aws_iam_policy_document.bedrock_invoke: Reading...
data.aws_iam_policy_document.bedrock_invoke: Read complete after 0s [id=3601248236]
module.network.data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_rds_engine_version.aurora_pg: Read complete after 0s [id=17.9]
data.aws_iam_openid_connect_provider.github: Read complete after 0s [id=arn:aws:iam::797781631727:oidc-provider/token.actions.githubusercontent.com]
data.aws_iam_policy_document.ci_deploy_dev: Reading...
data.aws_iam_policy_document.ci_deploy_dev: Read complete after 0s [id=1754478413]
data.aws_iam_policy_document.ci_deploy_dev_trust: Reading...
data.aws_iam_policy_document.ci_deploy_dev_trust: Read complete after 0s [id=4060172364]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place

Terraform will perform the following actions:

  # module.operations.aws_cloudwatch_dashboard.operations will be updated in-place
  ~ resource "aws_cloudwatch_dashboard" "operations" {
      ~ dashboard_body = jsonencode(
          ~ {
              ~ widgets = [
                  ~ {
                      ~ properties = {
                          ~ markdown = <<-EOT
                                # ER dev operations (shared deployment)
                              - API errors are the 5xx response series. Queue and concurrency are current gauges; the snapshot heartbeat below must be present before an empty chart means idle. Counters are interval deltas, so rates divide Sum by the period. Duration charts use means, not percentiles.
                              + API errors are the 5xx response series. Queue and concurrency are current gauges; the database and managed-pod snapshot heartbeats must be present before an empty age chart means idle. A missing or zero pod heartbeat means Kubernetes observations are unavailable even if database snapshots continue. Counters are interval deltas, so rates divide Sum by the period. Duration charts use means, not percentiles.
                                
                                Per-tenant data quality remains in the authenticated dataset dashboard (`/{org}/{dataset}/dashboard`) and dataset `/metrics` API, backed by durable lake data. Tenant and dataset identifiers never become CloudWatch dimensions. Task counters are operational observations, not an accounting ledger.
                            EOT
                        }
                        # (5 unchanged attributes hidden)
                    },
                    {
                        height     = 6
                        properties = {
                            metrics = [
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "1xx",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "1xx"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "2xx",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "2xx"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "3xx",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "3xx"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "4xx",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "4xx"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "5xx",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "5xx"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.http.requests",
                                    "status_class",
                                    "other",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "other"
                                    },
                                ],
                            ]
                            period  = 60
                            region  = "us-east-2"
                            stat    = "Sum"
                            title   = "API responses / minute"
                            view    = "timeSeries"
                        }
                        type       = "metric"
                        width      = 12
                        x          = 0
                        y          = 4
                    },
                    # (11 unchanged elements hidden)
                    {
                        height     = 6
                        properties = {
                            metrics = [
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "S",
                                    "reason",
                                    "oom",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "S oom"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "S",
                                    "reason",
                                    "evicted",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "S evicted"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "M",
                                    "reason",
                                    "oom",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "M oom"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "M",
                                    "reason",
                                    "evicted",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "M evicted"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "L",
                                    "reason",
                                    "oom",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "L oom"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "L",
                                    "reason",
                                    "evicted",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "L evicted"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "other",
                                    "reason",
                                    "oom",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "other oom"
                                    },
                                ],
                                [
                                    "ER/Dev",
                                    "er.pods.failures",
                                    "resource_class",
                                    "other",
                                    "reason",
                                    "evicted",
                                    "OTelLib",
                                    "er-obs",
                                    {
                                        label = "other evicted"
                                    },
                                ],
                            ]
                            period  = 60
                            region  = "us-east-2"
                            stat    = "Sum"
                            title   = "Confirmed pod OOM kills and evictions / minute"
                            view    = "timeSeries"
                        }
                        type       = "metric"
                        width      = 24
                        x          = 0
                        y          = 40
                    },
                  + {
                      + height     = 6
                      + properties = {
                          + metrics = [
                              + [
                                  + "ER/Dev",
                                  + "er.jobs.queue.oldest_age",
                                  + "OTelLib",
                                  + "er-obs",
                                ],
                            ]
                          + period  = 60
                          + region  = "us-east-2"
                          + stat    = "Maximum"
                          + title   = "Oldest queued job (seconds, includes backoff)"
                          + view    = "timeSeries"
                        }
                      + type       = "metric"
                      + width      = 12
                      + x          = 0
                      + y          = 46
                    },
                  + {
                      + height     = 6
                      + properties = {
                          + metrics = [
                              + [
                                  + "ER/Dev",
                                  + "er.pods.pending.oldest_age",
                                  + "OTelLib",
                                  + "er-obs",
                                ],
                            ]
                          + period  = 60
                          + region  = "us-east-2"
                          + stat    = "Maximum"
                          + title   = "Oldest Pending runner pod (seconds)"
                          + view    = "timeSeries"
                        }
                      + type       = "metric"
                      + width      = 12
                      + x          = 12
                      + y          = 46
                    },
                  + {
                      + height     = 6
                      + properties = {
                          + metrics = [
                              + [
                                  + "ER/Dev",
                                  + "er.pods.snapshots",
                                  + "OTelLib",
                                  + "er-obs",
                                ],
                            ]
                          + period  = 60
                          + region  = "us-east-2"
                          + stat    = "Sum"
                          + title   = "Successful managed-pod snapshots / minute (expected about 2)"
                          + view    = "timeSeries"
                        }
                      + type       = "metric"
                      + width      = 24
                      + x          = 0
                      + y          = 52
                    },
                ]
            }
        )
        id             = "er-dev-operations"
        # (3 unchanged attributes hidden)
    }

  # module.operations.aws_cloudwatch_metric_alarm.age["pending"] will be created
  + resource "aws_cloudwatch_metric_alarm" "age" {
      + actions_enabled                       = true
      + alarm_actions                         = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + alarm_description                     = "Oldest Pending runner pod (seconds) exceeds 600 seconds. Inspect pod scheduling, image pulls, node capacity and account vCPU quotas. Require the matching snapshot heartbeat before treating a quiet chart as healthy."
      + alarm_name                            = "er-dev-pod-pending"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanThreshold"
      + datapoints_to_alarm                   = 1
      + dimensions                            = {
          + "OTelLib" = "er-obs"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "er.pods.pending.oldest_age"
      + namespace                             = "ER/Dev"
      + ok_actions                            = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + period                                = 60
      + region                                = "us-east-2"
      + statistic                             = "Maximum"
      + tags_all                              = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + threshold                             = 600
      + treat_missing_data                    = "notBreaching"
    }

  # module.operations.aws_cloudwatch_metric_alarm.age["queue"] will be created
  + resource "aws_cloudwatch_metric_alarm" "age" {
      + actions_enabled                       = true
      + alarm_actions                         = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + alarm_description                     = "Oldest queued job (seconds, includes backoff) exceeds 900 seconds. Inspect dispatcher readiness, job backoff, concurrency and runner capacity. Require the matching snapshot heartbeat before treating a quiet chart as healthy."
      + alarm_name                            = "er-dev-queue-oldest"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanThreshold"
      + datapoints_to_alarm                   = 1
      + dimensions                            = {
          + "OTelLib" = "er-obs"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "er.jobs.queue.oldest_age"
      + namespace                             = "ER/Dev"
      + ok_actions                            = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + period                                = 60
      + region                                = "us-east-2"
      + statistic                             = "Maximum"
      + tags_all                              = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + threshold                             = 900
      + treat_missing_data                    = "notBreaching"
    }

  # module.operations.aws_cloudwatch_metric_alarm.pod_snapshot_missing will be created
  + resource "aws_cloudwatch_metric_alarm" "pod_snapshot_missing" {
      + actions_enabled                       = true
      + alarm_actions                         = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + alarm_description                     = "No successful managed-pod snapshots for three minutes. Inspect Kubernetes API access, dispatcher readiness and metric export; the pending-age gauge is stale until this recovers. Database snapshots are independent."
      + alarm_name                            = "er-dev-pod-snapshot-missing"
      + arn                                   = (known after apply)
      + comparison_operator                   = "LessThanThreshold"
      + datapoints_to_alarm                   = 3
      + dimensions                            = {
          + "OTelLib" = "er-obs"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 3
      + id                                    = (known after apply)
      + metric_name                           = "er.pods.snapshots"
      + namespace                             = "ER/Dev"
      + ok_actions                            = [
          + "arn:aws:sns:us-east-2:797781631727:er-alerts",
        ]
      + period                                = 60
      + region                                = "us-east-2"
      + statistic                             = "Sum"
      + tags_all                              = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + threshold                             = 1
      + treat_missing_data                    = "breaching"
    }

Plan: 3 to add, 1 to change, 0 to destroy.

@athvin
athvin marked this pull request as ready for review November 9, 2026 13:27
@athvin
athvin merged commit 3169359 into main Nov 9, 2026
47 checks passed
athvin added a commit that referenced this pull request Nov 27, 2026
… interruptions, impersonation volume (#877)

* feat(obs): the three remaining standalone alarms — failure rate, spot interruptions, impersonation volume (#877)

#1051 shipped queue-oldest and pod-pending; these complete #877's five,
each an aggregate with no tenant dimension:

- attempt failure rate: failed ÷ (failed + done) of er.tasks.completed over
  an hour across classes, > 25% with at least 4 attempts. no_op/skipped are
  left out to stay within the alarm's ten-query ceiling.
- spot interruptions: an EventBridge rule on aws.ec2 "EC2 Spot Instance
  Interruption Warning" and an alarm on its MatchedEvents, > 5/h.
- impersonation volume: the BFF's writeAudit prints one identity-free
  `er.audit.impersonation` line per impersonation event; a log metric
  filter on the containers log group counts it, > 20/h.

Thresholds are module variables; the impersonation pair is skipped when no
log group is given. Wired in dev and prod; tftest covers each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style(infra): terraform fmt the module test

The fmt + validate gate runs fmt -check recursively; the earlier fmt ran in
the module directory alone and skipped tests/.

---------

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Alert on pending runner pods and oldest queued jobs

2 participants