4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
118 lines
4.7 KiB
Python
118 lines
4.7 KiB
Python
"""Starter alert payload templates for investigations."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
def build_alert_template(template_name: str) -> dict[str, Any]:
|
|
"""Return a starter alert payload template by name."""
|
|
template = template_name.strip().lower()
|
|
|
|
if template == "generic":
|
|
return {
|
|
"alert_name": "High error rate in payments ETL",
|
|
"pipeline_name": "payments_etl",
|
|
"severity": "critical",
|
|
"alert_source": "generic",
|
|
"message": "payments_etl is failing with repeated database connection errors",
|
|
"commonAnnotations": {
|
|
"summary": "payments_etl is failing with repeated database connection errors",
|
|
"correlation_id": "replace-me",
|
|
},
|
|
}
|
|
|
|
if template == "datadog":
|
|
return {
|
|
"title": "[Triggered] payments-etl error rate high",
|
|
"alert_name": "Datadog monitor: payments-etl error rate high",
|
|
"pipeline_name": "payments_etl",
|
|
"severity": "critical",
|
|
"alert_source": "datadog",
|
|
"message": "Datadog monitor detected repeated errors in payments_etl",
|
|
"text": "payments_etl is failing in production",
|
|
"commonLabels": {
|
|
"pipeline_name": "payments_etl",
|
|
"severity": "critical",
|
|
},
|
|
"commonAnnotations": {
|
|
"summary": "payments_etl is failing in production",
|
|
"query": "service:payments-etl status:error",
|
|
"kube_namespace": "payments",
|
|
"correlation_id": "replace-me",
|
|
},
|
|
}
|
|
|
|
if template == "grafana":
|
|
return {
|
|
"title": "[FIRING:1] Pipeline failure rate high - payments_etl",
|
|
"alert_name": "Grafana alert: Pipeline failure rate high",
|
|
"pipeline_name": "payments_etl",
|
|
"severity": "critical",
|
|
"alert_source": "grafana",
|
|
"state": "alerting",
|
|
"externalURL": "https://your-grafana-instance.grafana.net",
|
|
"commonLabels": {
|
|
"alertname": "PipelineFailureRateHigh",
|
|
"severity": "critical",
|
|
"pipeline_name": "payments_etl",
|
|
"grafana_folder": "production-pipelines",
|
|
},
|
|
"commonAnnotations": {
|
|
"summary": "payments_etl stopped updating after repeated failures",
|
|
"source_url": "https://your-grafana-instance.grafana.net/explore",
|
|
"execution_run_id": "replace-me",
|
|
"correlation_id": "replace-me",
|
|
},
|
|
}
|
|
|
|
if template == "honeycomb":
|
|
return {
|
|
"alert_name": "Honeycomb alert: checkout-api latency regression",
|
|
"pipeline_name": "checkout_api",
|
|
"severity": "critical",
|
|
"alert_source": "honeycomb",
|
|
"message": "Honeycomb detected high latency in checkout_api spans",
|
|
"service_name": "checkout-api",
|
|
"trace_id": "replace-me",
|
|
"commonAnnotations": {
|
|
"summary": "checkout-api spans are timing out in production",
|
|
"service_name": "checkout-api",
|
|
"trace_id": "replace-me",
|
|
},
|
|
}
|
|
|
|
if template == "coralogix":
|
|
return {
|
|
"alert_name": "Coralogix alert: payments worker errors",
|
|
"pipeline_name": "payments_worker",
|
|
"severity": "critical",
|
|
"alert_source": "coralogix",
|
|
"message": "Coralogix detected repeated exceptions in payments_worker",
|
|
"application_name": "payments",
|
|
"subsystem_name": "worker",
|
|
"commonAnnotations": {
|
|
"summary": "payments worker is logging repeated timeout exceptions",
|
|
"application_name": "payments",
|
|
"subsystem_name": "worker",
|
|
"log_query": "source logs | filter $l.applicationname == 'payments' | limit 50",
|
|
},
|
|
}
|
|
|
|
if template == "splunk":
|
|
return {
|
|
"alert_name": "Splunk alert: payments service error spike",
|
|
"pipeline_name": "payments_service",
|
|
"severity": "critical",
|
|
"alert_source": "splunk",
|
|
"message": "Splunk detected repeated NullPointerExceptions in payments_service",
|
|
"commonAnnotations": {
|
|
"summary": "payments_service is logging repeated NullPointerExceptions",
|
|
"splunk_query": 'index=main source="/var/log/payments*" "NullPointerException" | head 50',
|
|
},
|
|
}
|
|
|
|
raise ValueError(
|
|
"Unknown alert template. Supported templates: generic, datadog, grafana, honeycomb, coralogix, splunk."
|
|
)
|