This package implements the PubSub listener for event-driven anomaly backfilling.
The Listener waits for messages on a configured PubSub topic. Each message contains a BackfillRequest with a RequestID, an AlertID and an End timestamp (which we consider as the processing date).
Note on the End timestamp: The anomaly detection logic will load the latest N commits (where N is determined by the NumContinuous flag) ending at or before the specified End timestamp. We do not specify the number of commits N in the request because commit density can vary, and it is safer to rely on the standard configured number of commits to ensure we cover the expected range for detection.
When a message is received, the listener:
TraceIDs is provided in the request, it filters out traces that do not match the alert's query and only processes the matching ones.LoadAllTracesTogether is true): Loads and processes all traces in a single data frame.SendNotifications is true in the request; otherwise, it only saves the data.To enable the backfill listener, you must configure the following in your instance configuration:
{ "anomaly_config": { "backfill_topic_name": "your-topic-name", "backfill_concurrency": 2 } }
The listener is started from Continuous.Run() if backfill_topic_name is set.
You can use the trigger_backfill.sh script to trigger a backfill manually by publishing to the Pub/Sub topic.
[!NOTE] The script will iterate through the date range (from
<start_date>to<finish_date>) and publish a separate Pub/Sub message for each day and each alert_id.
Usage:
./trigger_backfill.sh [-n] [-a] [-i <request_id>] [-f <trace_file>] <project> <topic> <start_date> <finish_date> <alert_id1> [<alert_id2> ...]
Options:
-n: Enable sending notifications (default: false).-a: Load all traces together (default: false).-i <request_id>: Use a custom request ID (default: auto-generated UUID).-f <trace_file>: File containing trace IDs (one per line). Use - to read from stdin.Examples:
Standard backfill with notifications:
./trigger_backfill.sh -n skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345 67890
Backfill all traces together with a custom request ID:
./trigger_backfill.sh -a -i "my-custom-batch-id" skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345 67890
Backfill specific traces from a file:
./trigger_backfill.sh -f traces.txt skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345
Backfill specific traces via pipe:
cat traces.txt | ./trigger_backfill.sh -f - skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345
To perform a backfill, follow these steps:
[!IMPORTANT] To have access to write data into the topic, you need to use breakglass. Please refer to the instructions for details.
Find the IDs of the alerts you want to backfill by querying the alerts table in Spanner.
Use the trigger_backfill.sh script to publish requests for the desired date range and alert IDs.
./trigger_backfill.sh [-n] [-a] [-i <request_id>] [-f <trace_file>] <project> <topic> <start_date> <finish_date> <alert_id1> [<alert_id2> ...]
./trigger_backfill.sh -a -n -i "my-custom-batch-id" skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345 67890
./trigger_backfill.sh -f traces.txt skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345
cat traces.txt | ./trigger_backfill.sh -f - skia-public perf-anomaly-backfill-v8-perf-autopush 2026-01-01 2026-01-05 12345
Monitor the following metrics to track the progress and health of the backfill process:
perf_backfill_runs_total: Total number of backfill requests processed.perf_backfill_success_total: Number of successful backfill requests.perf_backfill_failure_total: Number of requests that failed with fatal errors (e.g., missing alert).perf_backfill_errors_total: Number of requests that encountered non-fatal errors and will be retried."Failed to process backfill message": Indicates a message processing failure. Look at the associated error details."Acking unprocessable message": Indicates a message was dropped (acked) because it cannot be processed (e.g., invalid alert ID) to prevent infinite retries.