forked from mtusi2026/mtusi2026lab6
Реализовать лабораторную 6 на 5: SLO и обнаружение инцидентов
This commit is contained in:
@@ -0,0 +1,618 @@
|
||||
{
|
||||
"uid": "messenger-lab6",
|
||||
"title": "Messenger — Lab 6: signals and SLO",
|
||||
"schemaVersion": 41,
|
||||
"version": 1,
|
||||
"refresh": "5s",
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"tags": [
|
||||
"lab6",
|
||||
"slo"
|
||||
],
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Business API RPS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (method, route) (rate(messenger_http_requests_total[1m]))",
|
||||
"legendFormat": "{{method}} {{route}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API 5xx / all business requests",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "lab6:api_bad_ratio:1m",
|
||||
"legendFormat": "API 5xx / all business requests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "API latency: aggregated histogram",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Seconds to response headers; excludes health. Sum buckets across replicas before percentile.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Time from acceptance to ready: completed jobs",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Success histogram only. SLO below also includes jobs that never complete.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Job attempts by outcome",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (outcome) (rate(messenger_job_attempts_total[1m]))",
|
||||
"legendFormat": "{{outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Worker processing p95",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(messenger_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "{{outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Outstanding jobs (DB source of truth)",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Queued + processing durable jobs, including retry/outbox; not Redis XLEN.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_depth)",
|
||||
"legendFormat": "Outstanding jobs (DB source of truth)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Oldest unfinished job age",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_oldest_age_seconds)",
|
||||
"legendFormat": "Oldest unfinished job age"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "DB pool used / waiting",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name, state) (messenger_db_pool)",
|
||||
"legendFormat": "{{service_name}} {{state}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Worker busy / capacity",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(messenger_worker_busy) or vector(0)",
|
||||
"legendFormat": "busy"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum(messenger_worker_capacity) or vector(0)",
|
||||
"legendFormat": "capacity"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "Process CPU: cores consumed",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name) (rate(messenger_process_cpu_time_seconds_total[1m]))",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "Process RSS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name) (messenger_process_memory_bytes)",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "API availability SLO: >= 99% / 1h",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "5xx bad; all instrumented business requests denominator; 4xx not server failures.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "1-lab6:api_bad_ratio:1h",
|
||||
"legendFormat": "API availability SLO: >= 99% / 1h"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"title": "Ready SLO: >= 95% within 30s / 1h",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Acceptance cohorts mature after 30s. Failed, stuck and late jobs are BAD. No ready-only bias.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "1-lab6:ready_bad_ratio:1h",
|
||||
"legendFormat": "Ready SLO: >= 95% within 30s / 1h"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"title": "API burn rate (budget / hour)",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Fast: 2m AND 30s > 6x, for 15s. Slow: 6m AND 1m > 3x, for 30s.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "lab6:api_bad_ratio:30s/0.01",
|
||||
"legendFormat": "30s"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "lab6:api_bad_ratio:2m/0.01",
|
||||
"legendFormat": "2m"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "lab6:api_bad_ratio:1m/0.01",
|
||||
"legendFormat": "1m"
|
||||
},
|
||||
{
|
||||
"refId": "D",
|
||||
"expr": "lab6:api_bad_ratio:6m/0.01",
|
||||
"legendFormat": "6m"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"title": "Ready burn rate (budget / hour)",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "Fast: 2m AND 30s > 6x, for 15s. Slow: 6m AND 1m > 3x, for 30s.",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "lab6:ready_bad_ratio:30s/0.05",
|
||||
"legendFormat": "30s"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "lab6:ready_bad_ratio:2m/0.05",
|
||||
"legendFormat": "2m"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "lab6:ready_bad_ratio:1m/0.05",
|
||||
"legendFormat": "1m"
|
||||
},
|
||||
{
|
||||
"refId": "D",
|
||||
"expr": "lab6:ready_bad_ratio:6m/0.05",
|
||||
"legendFormat": "6m"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"title": "Local alert states",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 64,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"description": "",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "ALERTS{alertstate=~\"pending|firing\"}",
|
||||
"legendFormat": "{{alertname}} {{alertstate}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"title": "API / worker structured logs (click TraceID)",
|
||||
"type": "logs",
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 64,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=~\"messenger-api|messenger-worker\"} | json"
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"showTime": true,
|
||||
"wrapLogMessage": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"title": "Recent real worker traces",
|
||||
"type": "table",
|
||||
"datasource": {
|
||||
"type": "tempo",
|
||||
"uid": "tempo"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 72,
|
||||
"w": 24,
|
||||
"h": 9
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"queryType": "traceql",
|
||||
"query": "{ resource.service.name = \"messenger-worker\" }",
|
||||
"limit": 20,
|
||||
"tableType": "traces",
|
||||
"filters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"annotations": {
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: messenger
|
||||
folder: Lab 6
|
||||
type: file
|
||||
disableDeletion: false
|
||||
updateIntervalSeconds: 10
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,35 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
jsonData:
|
||||
timeInterval: 5s
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- name: TraceID
|
||||
matcherRegex: '"trace_id": "([a-f0-9]{32})"'
|
||||
datasourceUid: tempo
|
||||
url: '$${__value.raw}'
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
jsonData:
|
||||
tracesToLogs:
|
||||
datasourceUid: loki
|
||||
spanStartTimeShift: '-1m'
|
||||
spanEndTimeShift: '1m'
|
||||
filterByTraceID: true
|
||||
tags: [{key: service.name, value: service_name}]
|
||||
nodeGraph:
|
||||
enabled: true
|
||||
@@ -0,0 +1,40 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 256
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option dontlognull
|
||||
option http-server-close
|
||||
timeout connect 1s
|
||||
timeout client 40s
|
||||
timeout server 60s
|
||||
timeout http-request 5s
|
||||
timeout check 1s
|
||||
retries 1
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
accepted_payload_size 8192
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold obsolete 1s
|
||||
hold nx 1s
|
||||
hold timeout 1s
|
||||
hold refused 1s
|
||||
hold other 1s
|
||||
|
||||
frontend public
|
||||
bind :8080
|
||||
default_backend api
|
||||
|
||||
backend api
|
||||
balance roundrobin
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host localhost
|
||||
http-check expect status 200
|
||||
default-server inter 1s fastinter 1s downinter 1s fall 2 rise 2
|
||||
server-template replica 10 api:8080 check resolvers docker resolve-prefer ipv4 init-addr none
|
||||
@@ -0,0 +1,113 @@
|
||||
groups:
|
||||
- name: messenger-slo
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: lab6:api_bad_ratio:30s
|
||||
expr: (sum(rate(messenger_http_requests_total{status_class="5xx"}[30s])) or vector(0))
|
||||
/ sum(rate(messenger_http_requests_total[30s]))
|
||||
- record: lab6:ready_bad_ratio:30s
|
||||
expr: sum(rate(messenger_ready_deadlines_total{outcome="bad"}[30s])) / sum(rate(messenger_ready_deadlines_total[30s]))
|
||||
- record: lab6:api_bad_ratio:1m
|
||||
expr: (sum(rate(messenger_http_requests_total{status_class="5xx"}[1m])) or vector(0))
|
||||
/ sum(rate(messenger_http_requests_total[1m]))
|
||||
- record: lab6:ready_bad_ratio:1m
|
||||
expr: sum(rate(messenger_ready_deadlines_total{outcome="bad"}[1m])) / sum(rate(messenger_ready_deadlines_total[1m]))
|
||||
- record: lab6:api_bad_ratio:2m
|
||||
expr: (sum(rate(messenger_http_requests_total{status_class="5xx"}[2m])) or vector(0))
|
||||
/ sum(rate(messenger_http_requests_total[2m]))
|
||||
- record: lab6:ready_bad_ratio:2m
|
||||
expr: sum(rate(messenger_ready_deadlines_total{outcome="bad"}[2m])) / sum(rate(messenger_ready_deadlines_total[2m]))
|
||||
- record: lab6:api_bad_ratio:6m
|
||||
expr: (sum(rate(messenger_http_requests_total{status_class="5xx"}[6m])) or vector(0))
|
||||
/ sum(rate(messenger_http_requests_total[6m]))
|
||||
- record: lab6:ready_bad_ratio:6m
|
||||
expr: sum(rate(messenger_ready_deadlines_total{outcome="bad"}[6m])) / sum(rate(messenger_ready_deadlines_total[6m]))
|
||||
- record: lab6:api_bad_ratio:1h
|
||||
expr: (sum(rate(messenger_http_requests_total{status_class="5xx"}[1h])) or vector(0))
|
||||
/ sum(rate(messenger_http_requests_total[1h]))
|
||||
- record: lab6:ready_bad_ratio:1h
|
||||
expr: sum(rate(messenger_ready_deadlines_total{outcome="bad"}[1h])) / sum(rate(messenger_ready_deadlines_total[1h]))
|
||||
- alert: APIAvailabilityFastBurn
|
||||
expr: (lab6:api_bad_ratio:2m > 6 * 0.01) and (lab6:api_bad_ratio:30s > 6 * 0.01)
|
||||
and (sum(increase(messenger_http_requests_total[2m])) >= 30) and (sum(increase(messenger_http_requests_total[30s]))
|
||||
>= 2)
|
||||
for: 15s
|
||||
labels:
|
||||
severity: critical
|
||||
slo: api
|
||||
annotations:
|
||||
summary: 'api: 6x budget burn in both 2m and 30s'
|
||||
description: Budget 0.01; rolling SLO window 1h. Requires real traffic, not
|
||||
health requests.
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#api
|
||||
runbook: docs/runbook.md#api
|
||||
- alert: APIAvailabilitySlowBurn
|
||||
expr: (lab6:api_bad_ratio:6m > 3 * 0.01) and (lab6:api_bad_ratio:1m > 3 * 0.01)
|
||||
and (sum(increase(messenger_http_requests_total[6m])) >= 30) and (sum(increase(messenger_http_requests_total[1m]))
|
||||
>= 2)
|
||||
for: 30s
|
||||
labels:
|
||||
severity: warning
|
||||
slo: api
|
||||
annotations:
|
||||
summary: 'api: 3x budget burn in both 6m and 1m'
|
||||
description: Budget 0.01; rolling SLO window 1h. Requires real traffic, not
|
||||
health requests.
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#api
|
||||
runbook: docs/runbook.md#api
|
||||
- alert: AttachmentReadyFastBurn
|
||||
expr: (lab6:ready_bad_ratio:2m > 6 * 0.05) and (lab6:ready_bad_ratio:30s > 6 *
|
||||
0.05) and (sum(increase(messenger_ready_deadlines_total[2m])) >= 5) and (sum(increase(messenger_ready_deadlines_total[30s]))
|
||||
>= 2)
|
||||
for: 15s
|
||||
labels:
|
||||
severity: critical
|
||||
slo: ready
|
||||
annotations:
|
||||
summary: 'ready: 6x budget burn in both 2m and 30s'
|
||||
description: Budget 0.05; rolling SLO window 1h. Requires real traffic, not
|
||||
health requests.
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#ready
|
||||
runbook: docs/runbook.md#ready
|
||||
- alert: AttachmentReadySlowBurn
|
||||
expr: (lab6:ready_bad_ratio:6m > 3 * 0.05) and (lab6:ready_bad_ratio:1m > 3 *
|
||||
0.05) and (sum(increase(messenger_ready_deadlines_total[6m])) >= 5) and (sum(increase(messenger_ready_deadlines_total[1m]))
|
||||
>= 2)
|
||||
for: 30s
|
||||
labels:
|
||||
severity: warning
|
||||
slo: ready
|
||||
annotations:
|
||||
summary: 'ready: 3x budget burn in both 6m and 1m'
|
||||
description: Budget 0.05; rolling SLO window 1h. Requires real traffic, not
|
||||
health requests.
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#ready
|
||||
runbook: docs/runbook.md#ready
|
||||
- alert: APIHighErrorRate
|
||||
expr: lab6:api_bad_ratio:30s > 0.05
|
||||
for: 5s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: API 5xx > 5% for 30s (single-window comparator)
|
||||
runbook: docs/runbook.md#api
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#api
|
||||
- alert: AttachmentQueueLag
|
||||
expr: (max(messenger_queue_oldest_age_seconds) > 20) and (max(messenger_queue_depth)
|
||||
> 0)
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Oldest unfinished job exceeds 20s; queue not empty
|
||||
runbook: docs/runbook.md#ready
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#ready
|
||||
- alert: TelemetryCollectorUnavailable
|
||||
expr: up{job="collector"} == 0
|
||||
for: 15s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Collector scrape unavailable; SLI may be incomplete
|
||||
runbook: docs/runbook.md#telemetry
|
||||
runbook_url: https://gitea.privcloud.tech/Savelev_Ivan/mtusi2026lab6/src/branch/main/docs/runbook.md#telemetry
|
||||
@@ -0,0 +1,74 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 192
|
||||
spike_limit_mib: 32
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 64
|
||||
send_batch_max_size: 128
|
||||
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:9464
|
||||
metric_expiration: 30s
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
otlphttp/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 64
|
||||
retry_on_failure:
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
otlp/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls:
|
||||
insecure: true
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 64
|
||||
retry_on_failure:
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
|
||||
service:
|
||||
extensions: [health_check]
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlp/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
@@ -0,0 +1,37 @@
|
||||
auth_enabled: false
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
common:
|
||||
path_prefix: /loki
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/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: 168h
|
||||
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: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
@@ -0,0 +1,15 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
rule_files:
|
||||
- /etc/prometheus/alerts.yaml
|
||||
scrape_configs:
|
||||
- job_name: messenger
|
||||
static_configs:
|
||||
- targets: [otel-collector:9464]
|
||||
- job_name: collector
|
||||
static_configs:
|
||||
- targets: [otel-collector:8888]
|
||||
- job_name: prometheus
|
||||
static_configs:
|
||||
- targets: [localhost:9090]
|
||||
@@ -0,0 +1,20 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
ingester:
|
||||
max_block_duration: 1m
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 168h
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
Reference in New Issue
Block a user