This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 1024
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode tcp
|
||||
timeout connect 3s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
|
||||
frontend s3_tls
|
||||
bind :9000 ssl crt /run/secrets/dependency_pem ssl-min-ver TLSv1.3
|
||||
mode http
|
||||
default_backend s3_plain
|
||||
backend s3_plain
|
||||
mode http
|
||||
server minio minio:9000 check
|
||||
|
||||
frontend broker_tls
|
||||
bind :5671 ssl crt /run/secrets/dependency_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl worker_identity ssl_c_s_dn(cn) -m str worker
|
||||
acl dispatcher_identity ssl_c_s_dn(cn) -m str dispatcher
|
||||
tcp-request content reject unless worker_identity or dispatcher_identity
|
||||
default_backend broker_plain
|
||||
backend broker_plain
|
||||
server broker broker:5672 check
|
||||
|
||||
frontend redis_tls
|
||||
bind :6380 ssl crt /run/secrets/dependency_pem ssl-min-ver TLSv1.3
|
||||
default_backend redis_plain
|
||||
backend redis_plain
|
||||
server redis redis:6379 check
|
||||
@@ -0,0 +1,75 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
timeout connect 3s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
|
||||
frontend otlp_tls
|
||||
bind :4318 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required alpn h2,http/1.1 ssl-min-ver TLSv1.3
|
||||
acl api_identity ssl_c_s_dn(cn) -m str api
|
||||
acl worker_identity ssl_c_s_dn(cn) -m str worker
|
||||
acl dispatcher_identity ssl_c_s_dn(cn) -m str dispatcher
|
||||
http-request deny deny_status 403 unless api_identity or worker_identity or dispatcher_identity
|
||||
default_backend collector_otlp
|
||||
backend collector_otlp
|
||||
server collector otel-collector:4318 check
|
||||
|
||||
frontend collector_metrics_tls
|
||||
bind :8889 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl prometheus_identity ssl_c_s_dn(cn) -m str prometheus
|
||||
http-request deny deny_status 403 unless prometheus_identity
|
||||
default_backend collector_metrics
|
||||
backend collector_metrics
|
||||
server collector otel-collector:8889 check
|
||||
|
||||
frontend collector_internal_tls
|
||||
bind :8888 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl prometheus_identity ssl_c_s_dn(cn) -m str prometheus
|
||||
http-request deny deny_status 403 unless prometheus_identity
|
||||
default_backend collector_internal
|
||||
backend collector_internal
|
||||
server collector otel-collector:8888 check
|
||||
|
||||
frontend loki_tls
|
||||
bind :3100 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl collector_identity ssl_c_s_dn(cn) -m str otel-collector
|
||||
acl grafana_identity ssl_c_s_dn(cn) -m str grafana
|
||||
http-request deny deny_status 403 unless collector_identity or grafana_identity
|
||||
default_backend loki_plain
|
||||
backend loki_plain
|
||||
server loki loki:3100 check
|
||||
|
||||
frontend tempo_query_tls
|
||||
bind :3200 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl grafana_identity ssl_c_s_dn(cn) -m str grafana
|
||||
http-request deny deny_status 403 unless grafana_identity
|
||||
default_backend tempo_query
|
||||
backend tempo_query
|
||||
server tempo tempo:3200 check
|
||||
|
||||
frontend tempo_otlp_tls
|
||||
bind :4319 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl collector_identity ssl_c_s_dn(cn) -m str otel-collector
|
||||
http-request deny deny_status 403 unless collector_identity
|
||||
default_backend tempo_otlp
|
||||
backend tempo_otlp
|
||||
server tempo tempo:4318 check
|
||||
|
||||
frontend prometheus_tls
|
||||
bind :9090 ssl crt /run/secrets/telemetry_pem ca-file /run/secrets/tls_ca verify required ssl-min-ver TLSv1.3
|
||||
acl grafana_identity ssl_c_s_dn(cn) -m str grafana
|
||||
http-request deny deny_status 403 unless grafana_identity
|
||||
default_backend prometheus_plain
|
||||
backend prometheus_plain
|
||||
server prometheus prometheus:9090 check
|
||||
|
||||
frontend grafana_tls
|
||||
bind :3000 ssl crt /run/secrets/telemetry_pem alpn h2,http/1.1 ssl-min-ver TLSv1.3
|
||||
default_backend grafana_plain
|
||||
backend grafana_plain
|
||||
server grafana grafana:3000 check
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM haproxy:3.2-alpine@sha256:dfba86f031bd4c9039f10f8cc5de75991d1b6766d5460f0335b980408503baad
|
||||
|
||||
COPY infrastructure/haproxy/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
|
||||
|
||||
USER 1000:1000
|
||||
|
||||
EXPOSE 8443
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout connect 3s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
|
||||
frontend public_https
|
||||
bind :8443 ssl crt /run/secrets/ingress_pem alpn h2,http/1.1 ssl-min-ver TLSv1.3
|
||||
http-request set-header X-Forwarded-Proto https
|
||||
default_backend api_mtls
|
||||
|
||||
backend api_mtls
|
||||
balance leastconn
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/lb ver HTTP/1.1 hdr Host api
|
||||
http-check expect status 200
|
||||
default-server check inter 2s fall 2 rise 2 resolvers docker init-addr libc,none ssl ssl-min-ver TLSv1.3 verify required verifyhost api ca-file /run/secrets/tls_ca crt /run/secrets/lb_client_pem
|
||||
server-template api 8 api:8444
|
||||
@@ -0,0 +1,43 @@
|
||||
FROM golang:1.27.3-alpine@sha256:fa3d596898d9f126af7c01d14ee7597bab3f39cccf392ef36b69fe77cd681f18 AS minio-builder
|
||||
|
||||
ARG MINIO_VERSION=RELEASE.2025-10-15T17-29-55Z
|
||||
RUN CGO_ENABLED=0 GOBIN=/out go install github.com/minio/minio@${MINIO_VERSION}
|
||||
|
||||
FROM golang:1.27.3-alpine@sha256:fa3d596898d9f126af7c01d14ee7597bab3f39cccf392ef36b69fe77cd681f18 AS mc-builder
|
||||
|
||||
ARG MC_VERSION=RELEASE.2025-08-13T08-35-41Z
|
||||
RUN CGO_ENABLED=0 GOBIN=/out go install github.com/minio/mc@${MC_VERSION}
|
||||
|
||||
FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf AS server
|
||||
|
||||
RUN apk upgrade --no-cache && \
|
||||
apk add --no-cache ca-certificates wget && \
|
||||
addgroup -g 1000 minio && \
|
||||
adduser -u 1000 -G minio -s /sbin/nologin -D minio && \
|
||||
mkdir -p /data && \
|
||||
chown minio:minio /data
|
||||
|
||||
COPY --from=minio-builder /out/minio /usr/local/bin/minio
|
||||
|
||||
USER minio:minio
|
||||
VOLUME ["/data"]
|
||||
EXPOSE 9000
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=20 \
|
||||
CMD wget -qO- http://127.0.0.1:9000/minio/health/live >/dev/null || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/minio"]
|
||||
CMD ["server", "/data", "--address", ":9000"]
|
||||
|
||||
FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf AS client
|
||||
|
||||
RUN apk upgrade --no-cache && \
|
||||
apk add --no-cache ca-certificates && \
|
||||
addgroup -g 1000 minio && \
|
||||
adduser -u 1000 -G minio -s /sbin/nologin -D minio
|
||||
|
||||
COPY --from=mc-builder /out/mc /usr/local/bin/mc
|
||||
|
||||
USER minio:minio
|
||||
ENTRYPOINT ["/usr/local/bin/mc"]
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetBucketLocation", "s3:ListBucket"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__"]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:PutObject"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__/staging/*"]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetObject"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__/attachments/*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetBucketLocation", "s3:ListBucket"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__"]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetObject", "s3:DeleteObject"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__/staging/*"]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
|
||||
"Resource": ["arn:aws:s3:::__BUCKET__/attachments/*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM node:24-alpine@sha256:44fce696f38ba8c987c4db89954051000bbd05ffd8d8659ba15ed4a8602e937f AS frontend-build
|
||||
|
||||
WORKDIR /frontend
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/ ./
|
||||
RUN npm test && npm run build
|
||||
|
||||
FROM nginx:1.30.6-alpine@sha256:970364228b1e4f932abc22d321932816782cca8a20b85a77552a7cfe9acfb3b5
|
||||
|
||||
COPY infrastructure/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=frontend-build /frontend/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||||
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
path "secret/data/api" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
ui = false
|
||||
disable_mlock = true
|
||||
|
||||
storage "file" {
|
||||
path = "/openbao/data"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
tls_cert_file = "/run/secrets/openbao_cert"
|
||||
tls_key_file = "/run/secrets/openbao_key"
|
||||
tls_min_version = "tls13"
|
||||
}
|
||||
|
||||
api_addr = "https://openbao:8200"
|
||||
@@ -0,0 +1,3 @@
|
||||
path "secret/data/dispatcher" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
path "secret/data/worker" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"annotations": {"list": []},
|
||||
"editable": false,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 1,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "reqps"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 0},
|
||||
"id": 1,
|
||||
"options": {"legend": {"displayMode": "table", "placement": "bottom"}},
|
||||
"targets": [{"expr": "sum(rate(messenger_http_server_requests_total[1m]))", "legendFormat": "all requests", "refId": "A"}],
|
||||
"title": "API request rate",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "reqps"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 0},
|
||||
"id": 2,
|
||||
"options": {"legend": {"displayMode": "table", "placement": "bottom"}},
|
||||
"targets": [{"expr": "sum by (status_class) (rate(messenger_http_server_requests_total[1m]))", "legendFormat": "{{status_class}}", "refId": "A"}],
|
||||
"title": "API responses by status class",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 0},
|
||||
"id": 3,
|
||||
"options": {"legend": {"displayMode": "table", "placement": "bottom"}},
|
||||
"targets": [{"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_server_duration_seconds_bucket[5m])))", "legendFormat": "p95", "refId": "A"}],
|
||||
"title": "API duration",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "jobs"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
|
||||
"id": 4,
|
||||
"options": {"legend": {"displayMode": "table", "placement": "bottom"}},
|
||||
"targets": [{"expr": "sum by (outcome) (increase(messenger_worker_jobs_total[5m]))", "legendFormat": "{{outcome}}", "refId": "A"}],
|
||||
"title": "Worker jobs by outcome",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
|
||||
"id": 5,
|
||||
"options": {"legend": {"displayMode": "table", "placement": "bottom"}},
|
||||
"targets": [{"expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(messenger_worker_job_duration_seconds_bucket[5m])))", "legendFormat": "p95 {{outcome}}", "refId": "A"}],
|
||||
"title": "Worker processing duration",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "loki", "uid": "loki"},
|
||||
"gridPos": {"h": 10, "w": 24, "x": 0, "y": 16},
|
||||
"id": 6,
|
||||
"options": {"dedupStrategy": "none", "enableLogDetails": true, "showCommonLabels": false, "showLabels": false, "showTime": true, "sortOrder": "Descending", "wrapLogMessage": true},
|
||||
"targets": [{"expr": "{service_name=~\"messenger-(api|worker)\"}", "queryType": "range", "refId": "A"}],
|
||||
"title": "Correlated structured logs",
|
||||
"type": "logs"
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 41,
|
||||
"tags": ["mtusi", "lab6", "grade3"],
|
||||
"templating": {"list": []},
|
||||
"time": {"from": "now-15m", "to": "now"},
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "MTUSI Lab 6 — Grade 3",
|
||||
"uid": "mtusi-lab7-grade3",
|
||||
"version": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,544 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": false,
|
||||
"graphTooltip": 1,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API RPS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(messenger_http_server_requests_total[1m]))",
|
||||
"legendFormat": "requests/s"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API 5xx ratio",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 0
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(messenger_http_server_requests_total{status_class=\"5xx\"}[1m])) / clamp_min(sum(rate(messenger_http_server_requests_total[1m])), 0.000001)",
|
||||
"legendFormat": "5xx / all"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "API latency p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_http_server_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_server_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_server_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Queue depth / oldest age seconds",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 7
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_depth)",
|
||||
"legendFormat": "depth"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "max(messenger_queue_oldest_job_age_seconds)",
|
||||
"legendFormat": "oldest age s"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 7
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_worker_busy) / clamp_min(max(messenger_worker_capacity), 1)",
|
||||
"legendFormat": "busy / capacity"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Time to ready p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 16,
|
||||
"y": 7
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "PostgreSQL pool used/idle/capacity",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name, state) (messenger_db_pool_connections)",
|
||||
"legendFormat": "{{service_name}} {{state}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "PostgreSQL pool waits",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 14
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name) (rate(messenger_db_pool_waits_total[5m]))",
|
||||
"legendFormat": "{{service_name}} waits/s"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Process CPU",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 16,
|
||||
"y": 14
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name) (rate(messenger_process_cpu_time_seconds_total[5m]))",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Process RSS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 21
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max by (service_name) (messenger_process_memory_bytes)",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "Worker jobs and p95 duration",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 21
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (outcome) (rate(messenger_worker_jobs_total[5m]))",
|
||||
"legendFormat": "jobs/s {{outcome}}"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(messenger_worker_job_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95 s {{outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "Collector bounded queues / drops",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 16,
|
||||
"y": 21
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "otelcol_exporter_queue_size",
|
||||
"legendFormat": "queue {{exporter}}"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "otelcol_exporter_queue_capacity",
|
||||
"legendFormat": "capacity {{exporter}}"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "(sum(rate(otelcol_exporter_send_failed_log_records[5m])) or vector(0)) + (sum(rate(otelcol_exporter_send_failed_spans[5m])) or vector(0))",
|
||||
"legendFormat": "drops/s"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "Alert state",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 28
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "ALERTS{alertname=~\"Messenger(APIHighErrorRate|QueueLagGrowing)\"}",
|
||||
"legendFormat": "{{alertname}} {{alertstate}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"title": "Correlated logs",
|
||||
"type": "logs",
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 16,
|
||||
"x": 8,
|
||||
"y": 28
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=~\"messenger-(api|worker|dispatcher)\"}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"dedupStrategy": "none",
|
||||
"enableLogDetails": true,
|
||||
"showCommonLabels": false,
|
||||
"showLabels": false,
|
||||
"showTime": true,
|
||||
"sortOrder": "Descending",
|
||||
"wrapLogMessage": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 41,
|
||||
"tags": [
|
||||
"mtusi",
|
||||
"lab6",
|
||||
"grade4"
|
||||
],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "MTUSI Lab 6 - Grade 4",
|
||||
"uid": "mtusi-lab7-grade4",
|
||||
"version": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"annotations": {"list": []},
|
||||
"editable": false,
|
||||
"graphTooltip": 1,
|
||||
"id": null,
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API error ratio by burn window",
|
||||
"type": "timeseries",
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"gridPos": {"h": 9, "w": 12, "x": 0, "y": 0},
|
||||
"fieldConfig": {"defaults": {"unit": "percentunit"}, "overrides": []},
|
||||
"targets": [
|
||||
{"refId": "A", "expr": "messenger:sli_api_error_ratio_30s", "legendFormat": "30s"},
|
||||
{"refId": "B", "expr": "messenger:sli_api_error_ratio_1m", "legendFormat": "1m"},
|
||||
{"refId": "C", "expr": "messenger:sli_api_error_ratio_2m", "legendFormat": "2m"},
|
||||
{"refId": "D", "expr": "messenger:sli_api_error_ratio_5m", "legendFormat": "5m"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Attachment >10s ratio by burn window",
|
||||
"type": "timeseries",
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"gridPos": {"h": 9, "w": 12, "x": 12, "y": 0},
|
||||
"fieldConfig": {"defaults": {"unit": "percentunit"}, "overrides": []},
|
||||
"targets": [
|
||||
{"refId": "A", "expr": "messenger:sli_attachment_slow_ratio_30s", "legendFormat": "30s"},
|
||||
{"refId": "B", "expr": "messenger:sli_attachment_slow_ratio_1m", "legendFormat": "1m"},
|
||||
{"refId": "C", "expr": "messenger:sli_attachment_slow_ratio_2m", "legendFormat": "2m"},
|
||||
{"refId": "D", "expr": "messenger:sli_attachment_slow_ratio_5m", "legendFormat": "5m"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "SLO compliance (7d policy window)",
|
||||
"type": "timeseries",
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 9},
|
||||
"fieldConfig": {"defaults": {"unit": "percentunit", "min": 0, "max": 1}, "overrides": []},
|
||||
"targets": [
|
||||
{"refId": "A", "expr": "messenger:slo_api_success_ratio_7d", "legendFormat": "API success"},
|
||||
{"refId": "B", "expr": "messenger:slo_attachment_ready_ratio_7d", "legendFormat": "ready <=10s"},
|
||||
{"refId": "C", "expr": "vector(0.99)", "legendFormat": "99% objective"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Burn-rate alert states",
|
||||
"type": "timeseries",
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 9},
|
||||
"fieldConfig": {"defaults": {"unit": "short"}, "overrides": []},
|
||||
"targets": [
|
||||
{"refId": "A", "expr": "ALERTS{alertname=~\"Messenger(API|AttachmentReady)BurnRate(Fast|Slow)\"}", "legendFormat": "{{alertname}} {{alertstate}}"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 42,
|
||||
"tags": ["mtusi", "lab6", "grade5", "slo", "burn-rate"],
|
||||
"templating": {"list": []},
|
||||
"time": {"from": "now-30m", "to": "now"},
|
||||
"timezone": "browser",
|
||||
"title": "MTUSI Lab 6 - Grade 5 SLO",
|
||||
"uid": "mtusi-lab7-grade5",
|
||||
"version": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: MTUSI Lab 6
|
||||
orgId: 1
|
||||
folder: Lab 6
|
||||
type: file
|
||||
disableDeletion: true
|
||||
editable: false
|
||||
updateIntervalSeconds: 10
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: https://telemetry-gateway:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: https://telemetry-gateway:3100
|
||||
editable: false
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- name: TraceID
|
||||
matcherRegex: '([0-9a-f]{32})'
|
||||
datasourceUid: tempo
|
||||
url: '$${__value.raw}'
|
||||
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: https://telemetry-gateway:3200
|
||||
editable: false
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
spanStartTimeShift: -1m
|
||||
spanEndTimeShift: 1m
|
||||
tags:
|
||||
- key: service.name
|
||||
value: service_name
|
||||
filterByTraceID: true
|
||||
filterBySpanID: true
|
||||
serviceMap:
|
||||
datasourceUid: prometheus
|
||||
nodeGraph:
|
||||
enabled: true
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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
|
||||
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
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: 48
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 256
|
||||
send_batch_max_size: 512
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_constant_labels:
|
||||
included: [service.name, service.version, service.instance.id, deployment.environment.name]
|
||||
otlp_http/tempo:
|
||||
endpoint: https://telemetry-gateway:4319
|
||||
tls:
|
||||
ca_file: /run/secrets/tls_ca
|
||||
cert_file: /run/secrets/collector_client_cert
|
||||
key_file: /run/secrets/collector_client_key
|
||||
timeout: 3s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 256
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
otlp_http/loki:
|
||||
endpoint: https://telemetry-gateway:3100/otlp
|
||||
tls:
|
||||
ca_file: /run/secrets/tls_ca
|
||||
cert_file: /run/secrets/collector_client_cert
|
||||
key_file: /run/secrets/collector_client_key
|
||||
timeout: 3s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 256
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
service:
|
||||
extensions: [health_check]
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlp_http/loki]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlp_http/tempo]
|
||||
telemetry:
|
||||
logs:
|
||||
level: info
|
||||
metrics:
|
||||
level: detailed
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
rule_files:
|
||||
- /etc/prometheus/rules/*.yaml
|
||||
scrape_configs:
|
||||
- job_name: application-telemetry
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /run/secrets/tls_ca
|
||||
server_name: telemetry-gateway
|
||||
cert_file: /run/secrets/prometheus_client_cert
|
||||
key_file: /run/secrets/prometheus_client_key
|
||||
static_configs:
|
||||
- targets: [telemetry-gateway:8889]
|
||||
- job_name: collector-internal
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /run/secrets/tls_ca
|
||||
server_name: telemetry-gateway
|
||||
cert_file: /run/secrets/prometheus_client_cert
|
||||
key_file: /run/secrets/prometheus_client_key
|
||||
static_configs:
|
||||
- targets: [telemetry-gateway:8888]
|
||||
@@ -0,0 +1,98 @@
|
||||
groups:
|
||||
- name: messenger-level4
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: messenger:sli_api_success_ratio_5m
|
||||
expr: 1 - (sum(rate(messenger_http_server_requests_total{status_class="5xx"}[5m])) / clamp_min(sum(rate(messenger_http_server_requests_total[5m])), 0.000001))
|
||||
- alert: MessengerAPIHighErrorRate
|
||||
expr: (sum(rate(messenger_http_server_requests_total{status_class="5xx"}[1m])) / clamp_min(sum(rate(messenger_http_server_requests_total[1m])), 0.000001)) > 0.01 and sum(rate(messenger_http_server_requests_total[1m])) > 0.05
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
slo: api-availability
|
||||
annotations:
|
||||
summary: API 5xx ratio exceeds the 99% availability SLO
|
||||
description: More than 1% of business HTTP requests were 5xx during the last minute.
|
||||
runbook: infrastructure/telemetry/runbooks/level4.md#api-high-error-rate
|
||||
- alert: MessengerQueueLagGrowing
|
||||
expr: max(messenger_queue_depth) > 0 and max(messenger_queue_oldest_job_age_seconds) > 10
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
slo: attachment-ready
|
||||
annotations:
|
||||
summary: Attachment queue lag is growing
|
||||
description: At least one job has remained queued for more than 10 seconds.
|
||||
runbook: infrastructure/telemetry/runbooks/level4.md#queue-lag-growing
|
||||
|
||||
- name: messenger-level5-burn-rate
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: messenger:slo_api_success_ratio_7d
|
||||
expr: (1 - (sum(increase(messenger_http_server_requests_total{status_class="5xx"}[7d])) / clamp_min(sum(increase(messenger_http_server_requests_total[7d])), 1))) and sum(increase(messenger_http_server_requests_total[7d])) > 0
|
||||
- record: messenger:slo_attachment_ready_ratio_7d
|
||||
expr: (sum(increase(messenger_attachment_ready_duration_seconds_bucket{le="10.0"}[7d])) / clamp_min(sum(increase(messenger_attachment_ready_duration_seconds_count[7d])), 1)) and sum(increase(messenger_attachment_ready_duration_seconds_count[7d])) > 0
|
||||
|
||||
- record: messenger:sli_api_error_ratio_30s
|
||||
expr: sum(rate(messenger_http_server_requests_total{status_class="5xx"}[30s])) / clamp_min(sum(rate(messenger_http_server_requests_total[30s])), 0.000001)
|
||||
- record: messenger:sli_api_error_ratio_1m
|
||||
expr: sum(rate(messenger_http_server_requests_total{status_class="5xx"}[1m])) / clamp_min(sum(rate(messenger_http_server_requests_total[1m])), 0.000001)
|
||||
- record: messenger:sli_api_error_ratio_2m
|
||||
expr: sum(rate(messenger_http_server_requests_total{status_class="5xx"}[2m])) / clamp_min(sum(rate(messenger_http_server_requests_total[2m])), 0.000001)
|
||||
- record: messenger:sli_api_error_ratio_5m
|
||||
expr: sum(rate(messenger_http_server_requests_total{status_class="5xx"}[5m])) / clamp_min(sum(rate(messenger_http_server_requests_total[5m])), 0.000001)
|
||||
|
||||
- record: messenger:sli_attachment_slow_ratio_30s
|
||||
expr: (sum(rate(messenger_attachment_ready_duration_seconds_count[30s])) - sum(rate(messenger_attachment_ready_duration_seconds_bucket{le="10.0"}[30s]))) / clamp_min(sum(rate(messenger_attachment_ready_duration_seconds_count[30s])), 0.000001)
|
||||
- record: messenger:sli_attachment_slow_ratio_1m
|
||||
expr: (sum(rate(messenger_attachment_ready_duration_seconds_count[1m])) - sum(rate(messenger_attachment_ready_duration_seconds_bucket{le="10.0"}[1m]))) / clamp_min(sum(rate(messenger_attachment_ready_duration_seconds_count[1m])), 0.000001)
|
||||
- record: messenger:sli_attachment_slow_ratio_2m
|
||||
expr: (sum(rate(messenger_attachment_ready_duration_seconds_count[2m])) - sum(rate(messenger_attachment_ready_duration_seconds_bucket{le="10.0"}[2m]))) / clamp_min(sum(rate(messenger_attachment_ready_duration_seconds_count[2m])), 0.000001)
|
||||
- record: messenger:sli_attachment_slow_ratio_5m
|
||||
expr: (sum(rate(messenger_attachment_ready_duration_seconds_count[5m])) - sum(rate(messenger_attachment_ready_duration_seconds_bucket{le="10.0"}[5m]))) / clamp_min(sum(rate(messenger_attachment_ready_duration_seconds_count[5m])), 0.000001)
|
||||
|
||||
- alert: MessengerAPIBurnRateFast
|
||||
expr: messenger:sli_api_error_ratio_30s > (14.4 * 0.01) and messenger:sli_api_error_ratio_2m > (14.4 * 0.01) and sum(rate(messenger_http_server_requests_total[30s])) > 0.1
|
||||
for: 10s
|
||||
labels:
|
||||
severity: page
|
||||
slo: api-availability
|
||||
burn_rate: fast
|
||||
annotations:
|
||||
summary: API consumes the 1% error budget at fast burn rate
|
||||
description: Both 30s and 2m windows exceed 14.4x burn rate.
|
||||
runbook: infrastructure/telemetry/runbooks/level5.md#api-burn-rate
|
||||
- alert: MessengerAPIBurnRateSlow
|
||||
expr: messenger:sli_api_error_ratio_1m > (6 * 0.01) and messenger:sli_api_error_ratio_5m > (6 * 0.01) and sum(rate(messenger_http_server_requests_total[1m])) > 0.05
|
||||
for: 20s
|
||||
labels:
|
||||
severity: ticket
|
||||
slo: api-availability
|
||||
burn_rate: slow
|
||||
annotations:
|
||||
summary: API consumes the 1% error budget at sustained burn rate
|
||||
description: Both 1m and 5m windows exceed 6x burn rate.
|
||||
runbook: infrastructure/telemetry/runbooks/level5.md#api-burn-rate
|
||||
- alert: MessengerAttachmentReadyBurnRateFast
|
||||
expr: messenger:sli_attachment_slow_ratio_30s > (14.4 * 0.01) and messenger:sli_attachment_slow_ratio_2m > (14.4 * 0.01) and sum(rate(messenger_attachment_ready_duration_seconds_count[30s])) > 0
|
||||
for: 10s
|
||||
labels:
|
||||
severity: page
|
||||
slo: attachment-ready
|
||||
burn_rate: fast
|
||||
annotations:
|
||||
summary: Attachment ready latency consumes its error budget quickly
|
||||
description: More than 14.4% of completed attachments exceed 10s in both windows.
|
||||
runbook: infrastructure/telemetry/runbooks/level5.md#attachment-ready-burn-rate
|
||||
- alert: MessengerAttachmentReadyBurnRateSlow
|
||||
expr: messenger:sli_attachment_slow_ratio_1m > (6 * 0.01) and messenger:sli_attachment_slow_ratio_5m > (6 * 0.01) and sum(rate(messenger_attachment_ready_duration_seconds_count[1m])) > 0
|
||||
for: 20s
|
||||
labels:
|
||||
severity: ticket
|
||||
slo: attachment-ready
|
||||
burn_rate: slow
|
||||
annotations:
|
||||
summary: Attachment ready latency consumes its error budget persistently
|
||||
description: More than 6% of completed attachments exceed 10s in both windows.
|
||||
runbook: infrastructure/telemetry/runbooks/level5.md#attachment-ready-burn-rate
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Runbook уровня 4
|
||||
|
||||
## API high error rate
|
||||
|
||||
1. Сравнить error ratio с RPS на dashboard.
|
||||
2. Найти в Loki `{service_name="messenger-api"} | status_class="5xx"`.
|
||||
3. Открыть `trace_id` в Tempo.
|
||||
4. Ошибочный `postgresql.*` client span указывает на БД; медленный server span без медленного DB child — на handler/внешнюю зависимость.
|
||||
5. Проверить DB pool used/capacity и rate waits.
|
||||
6. После восстановления создать успешные запросы и дождаться `resolved`.
|
||||
|
||||
## Queue lag growing
|
||||
|
||||
1. Сравнить `messenger_queue_depth` и `messenger_queue_oldest_job_age_seconds`.
|
||||
2. Проверить worker busy/capacity и `attachment_job_failed` в Loki.
|
||||
3. Открыть consumer trace и S3/PostgreSQL child spans.
|
||||
4. Восстановить worker; depth/age должны вернуться к нулю, alert — в `resolved`.
|
||||
|
||||
## Telemetry backend unavailable
|
||||
|
||||
1. Проверить `otelcol_exporter_queue_size`, capacity и failure counters.
|
||||
2. Memory limiter — 192 MiB при container limit 256 MiB; exporter queues — 256 batches.
|
||||
3. API/очередь не зависят от Loki/Tempo. После 30 s retry telemetry может отбрасываться — это bounded degradation.
|
||||
4. После восстановления backend проверить уменьшение очереди и появление новых сигналов.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Runbook уровня 5: SLO burn rate
|
||||
|
||||
## SLO и приоритет
|
||||
|
||||
- Policy window — 7 дней, что совпадает с retention Prometheus.
|
||||
- API availability SLO: не менее 99% HTTP-запросов без 5xx (`messenger:slo_api_success_ratio_7d`).
|
||||
- Attachment ready SLO: не менее 99% успешно завершённых attachments переходят в `ready` не позднее 10 секунд после durable acceptance (`messenger:slo_attachment_ready_ratio_7d`).
|
||||
- `fast` (14.4x, 30s + 2m) — page: бюджет расходуется достаточно быстро для немедленного вмешательства.
|
||||
- `slow` (6x, 1m + 5m) — ticket: деградация устойчивее, но допускает более спокойную диагностику.
|
||||
- Оба окна должны нарушаться одновременно. Traffic guard исключает алерт при отсутствии наблюдений.
|
||||
|
||||
## API burn rate
|
||||
|
||||
1. В Prometheus открыть `ALERTS{alertname=~"MessengerAPIBurnRate(Fast|Slow)"}` и записать `activeAt`.
|
||||
2. Сравнить `messenger:sli_api_error_ratio_30s`, `_1m`, `_2m`, `_5m` и RPS. Одно короткое окно без длинного не считается burn-rate инцидентом.
|
||||
3. В Loki выполнить `{service_name="messenger-api"} | status_class="5xx"` и взять свежие `request_id`/`trace_id`.
|
||||
4. Открыть trace в Tempo. `postgresql.acquire` error означает исчерпание/недоступность pool; `postgresql.*` query error — ошибку операции; медленный server span без DB/S3 child указывает на handler.
|
||||
5. Проверить `messenger_db_pool_connections`, `messenger_db_pool_waits_total`, process RAM/CPU и health зависимостей.
|
||||
6. Восстановить зависимость, создать контрольные успешные запросы. Зафиксировать момент исчезновения alert и recovery time.
|
||||
|
||||
## Attachment ready burn rate
|
||||
|
||||
1. Сравнить `messenger:sli_attachment_slow_ratio_30s`, `_1m`, `_2m`, `_5m` с queue depth/oldest age.
|
||||
2. Проверить `messenger_worker_busy / messenger_worker_capacity`; saturation около 1 при растущей очереди означает недостаточную worker capacity.
|
||||
3. Найти `attachment_job_failed`/`attachment_job_completed` в Loki и перейти по trace ID к producer/consumer spans.
|
||||
4. Ошибка `s3.*` указывает на object storage; `postgresql.*` — на DB; длинный разрыв между producer и consumer — на queue/worker.
|
||||
5. Восстановить worker/backend. Убедиться, что новые attachments укладываются в 10 секунд, оба burn-rate alert исчезли, queue age вернулся к нулю.
|
||||
|
||||
## Проверка ложного срабатывания
|
||||
|
||||
`tests/slo_burn_rate.py` сначала создаёт большой успешный baseline, затем короткий ограниченный 5xx burst. В течение observation window ни `Fast`, ни `Slow` не должны перейти в `pending` или `firing`. Далее тот же тест создаёт длительную DB-деградацию и измеряет detection/recovery. Это отделяет чувствительность к реальному расходованию бюджета от реакции на единичную ошибку.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 168h
|
||||
|
||||
Reference in New Issue
Block a user