feat: add bounded observability and verified SLO incident alerts

This commit is contained in:
Vladislav Agapov
2026-10-29 18:01:11 +03:00
parent 470d9d6f1e
commit 6c7601802d
325 changed files with 24988 additions and 44 deletions
@@ -0,0 +1,38 @@
groups:
- name: messenger-slo
interval: 5s
rules:
- record: messenger:api_error_ratio:1m
expr: sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics",status_class="5xx"}[1m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics"}[1m])), 0.001)
- record: messenger:api_error_ratio:5m
expr: sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics",status_class="5xx"}[5m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics"}[5m])), 0.001)
- alert: MessengerAPIBurnRate
expr: (messenger:api_error_ratio:1m > 0.05) and (messenger:api_error_ratio:5m > 0.05)
for: 30s
labels:
severity: warning
annotations:
summary: API consumes the 99% availability budget at more than 5x in both windows
runbook: REPORT.md#диагностика
- alert: MessengerReadyBurnRate
expr: ((sum(rate(messenger_ready_duration_seconds_count[1m])) - sum(rate(messenger_ready_duration_seconds_bucket{le=~"60|60.0"}[1m]))) / clamp_min(sum(rate(messenger_ready_duration_seconds_count[1m])), 0.001) > 0.25) and ((sum(rate(messenger_ready_duration_seconds_count[5m])) - sum(rate(messenger_ready_duration_seconds_bucket{le=~"60|60.0"}[5m]))) / clamp_min(sum(rate(messenger_ready_duration_seconds_count[5m])), 0.001) > 0.25)
for: 30s
labels:
severity: warning
annotations:
summary: More than 25% of completed jobs missed 60s in both windows (5x burn of 95% SLO)
runbook: REPORT.md#диагностика
- alert: MessengerQueueLag
expr: max(messenger_queue_oldest_seconds) > 60 and max(messenger_queue_depth) > 0
for: 15s
labels:
severity: warning
annotations:
summary: Accepted work has been waiting for over 60 seconds
runbook: REPORT.md#диагностика
- alert: MessengerTelemetryDrops
expr: sum(increase(otelcol_exporter_send_failed_spans_total[1m])) > 0
labels:
severity: info
annotations:
summary: Trace backend delivery is failing; inspect bounded collector queues
@@ -0,0 +1,71 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 192
spike_limit_mib: 48
batch:
timeout: 1s
send_batch_size: 128
send_batch_max_size: 256
exporters:
prometheus:
endpoint: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true
otlphttp/tempo:
endpoint: http://messenger-tempo:4318
timeout: 2s
sending_queue:
enabled: true
queue_size: 256
num_consumers: 2
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
otlphttp/loki:
endpoint: http://messenger-loki:3100/otlp
timeout: 2s
sending_queue:
enabled: true
queue_size: 256
num_consumers: 2
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp/tempo]
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp/loki]
@@ -0,0 +1,10 @@
apiVersion: 1
providers:
- name: messenger
orgId: 1
folder: Highload applications
type: file
disableDeletion: true
editable: false
options:
path: /dashboards
@@ -0,0 +1,35 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://messenger-prometheus:9090
isDefault: true
editable: false
- name: Loki
uid: loki
type: loki
access: proxy
url: http://messenger-loki:3100
editable: false
jsonData:
derivedFields:
- name: TraceID
matcherType: label
matcherRegex: trace_id
datasourceUid: tempo
url: '$${__value.raw}'
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: http://messenger-tempo:3200
editable: false
jsonData:
tracesToLogsV2:
datasourceUid: loki
filterByTraceID: true
spanStartTimeShift: '-1m'
spanEndTimeShift: '1m'
tags: [{key: service.name, value: service_name}]
@@ -0,0 +1,41 @@
auth_enabled: false
server:
http_listen_port: 3100
common:
path_prefix: /data
replication_factor: 1
ring:
kvstore:
store: inmemory
storage:
filesystem:
chunks_directory: /data/chunks
rules_directory: /data/rules
schema_config:
configs:
- from: 2024-01-01
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
limits_config:
allow_structured_metadata: true
retention_period: 24h
ingestion_rate_mb: 2
ingestion_burst_size_mb: 4
otlp_config:
resource_attributes:
ignore_defaults: true
attributes_config:
- action: index_label
attributes: [service.name, deployment.environment.name]
- action: structured_metadata
attributes: [service.instance.id, service.version]
compactor:
working_directory: /data/compactor
retention_enabled: true
delete_request_store: filesystem
analytics:
reporting_enabled: false
@@ -0,0 +1,519 @@
{
"uid": "messenger",
"title": "Messenger: API, worker and SLO",
"schemaVersion": 41,
"version": 1,
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
},
"panels": [
{
"id": 1,
"title": "HTTP RPS",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum by (route) (rate(messenger_http_requests_total{route!~\"/health/.*|/metrics\"}[1m]))"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 2,
"title": "API 5xx ratio",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(messenger_http_requests_total{status_class=\"5xx\",route!~\"/health/.*|/metrics\"}[1m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~\"/health/.*|/metrics\"}[1m])),0.001)"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 3,
"title": "HTTP latency p50/p95/p99",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 4,
"title": "Jobs by outcome",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum by (outcome) (rate(messenger_jobs_total[1m]))"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 5,
"title": "Job duration p95",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 6,
"title": "Time to ready p95",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_ready_duration_seconds_bucket[1m])))"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 7,
"title": "Queue depth",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "max(messenger_queue_depth)"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 8,
"title": "Oldest accepted job",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 24,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "max(messenger_queue_oldest_seconds)"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 9,
"title": "DB pool used/waiting",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 32,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(messenger_db_pool_used)"
},
{
"refId": "B",
"expr": "sum(messenger_db_pool_waiting)"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 10,
"title": "Worker saturation",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 32,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(messenger_worker_busy) / clamp_min(sum(messenger_worker_capacity),1)"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 11,
"title": "Process CPU",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 40,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum by (service_name) (rate(messenger_process_cpu_seconds_total[1m]))"
}
],
"fieldConfig": {
"defaults": {
"unit": "cores"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 12,
"title": "Process peak RSS",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 40,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "max by (service_name) (messenger_process_peak_rss_bytes)"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 13,
"title": "Collector queue and failed exports",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 48,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(otelcol_exporter_queue_size)"
},
{
"refId": "B",
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[1m]))"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 14,
"title": "Active alerts",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 48,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "ALERTS{alertstate=\"firing\"}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": [
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
}
]
}
@@ -0,0 +1,12 @@
global:
scrape_interval: 5s
evaluation_interval: 5s
rule_files:
- /config/alerts.yaml
scrape_configs:
- job_name: messenger
static_configs:
- targets: ['messenger-collector:8889']
- job_name: collector
static_configs:
- targets: ['messenger-collector:8888']
@@ -0,0 +1,24 @@
server:
http_listen_port: 3200
distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
storage:
trace:
backend: local
wal:
path: /data/wal
local:
path: /data/blocks
compactor:
compaction:
block_retention: 24h
ingester:
max_block_duration: 5m
usage_report:
reporting_enabled: false