forked from mtusi2026/mtusi2026lab6
Lab 6: track - 1
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
root_user=$(cat /run/secrets/rustfs_root_user)
|
||||
root_password=$(cat /run/secrets/rustfs_root_password)
|
||||
app_key=$(cat /run/secrets/s3_access_key_id)
|
||||
app_secret=$(cat /run/secrets/s3_secret_access_key)
|
||||
rc alias set local http://rustfs:9000 "$root_user" "$root_password"
|
||||
if ! rc bucket list local/ | grep -q 'messenger-attachments'; then
|
||||
rc bucket create local/messenger-attachments
|
||||
fi
|
||||
if ! rc admin policy info local messenger-objects >/dev/null 2>&1; then
|
||||
rc admin policy create local messenger-objects /policy.json
|
||||
fi
|
||||
if ! rc admin user info local "$app_key" >/dev/null 2>&1; then
|
||||
rc admin user add local "$app_key" "$app_secret"
|
||||
fi
|
||||
rc admin policy attach local messenger-objects --user "$app_key"
|
||||
@@ -0,0 +1,181 @@
|
||||
{
|
||||
"uid": "mtusi-lab6-obs",
|
||||
"title": "MTUSI Messenger — Lab 6 Observability",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "5s",
|
||||
"time": { "from": "now-15m", "to": "now" },
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "timeseries",
|
||||
"title": "API Business RPS (by route & status class)",
|
||||
"gridPos": { "x": 0, "y": 0, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "reqps" } },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (http_route, http_response_status_class) (rate(http_server_requests_total{service_name=\"messenger-api\",http_route!~\"/health/.*\"}[1m]))",
|
||||
"legendFormat": "{{http_route}} ({{http_response_status_class}})"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "timeseries",
|
||||
"title": "API 5xx Error Ratio (%)",
|
||||
"gridPos": { "x": 8, "y": 0, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0 } },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "100 * (sum(rate(http_server_requests_total{service_name=\"messenger-api\",http_route!~\"/health/.*\",http_response_status_class=\"5xx\"}[1m])) or vector(0)) / clamp_min(sum(rate(http_server_requests_total{service_name=\"messenger-api\",http_route!~\"/health/.*\"}[1m])), 1e-9)",
|
||||
"legendFormat": "5xx error %"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "timeseries",
|
||||
"title": "API Duration p50 / p95 / p99 (aggregated histogram)",
|
||||
"gridPos": { "x": 16, "y": 0, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s" } },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*\"}[1m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*\"}[1m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*\"}[1m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "timeseries",
|
||||
"title": "Worker Jobs Throughput (by outcome)",
|
||||
"gridPos": { "x": 0, "y": 8, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "ops" } },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (outcome) (rate(worker_jobs_total[1m]))",
|
||||
"legendFormat": "{{outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "timeseries",
|
||||
"title": "Job Processing & End-to-End Time to Ready (p50 / p95)",
|
||||
"gridPos": { "x": 8, "y": 8, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s" } },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(worker_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "job p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(worker_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "job p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(attachment_time_to_ready_seconds_bucket[1m])))",
|
||||
"legendFormat": "e2e ready p95"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "timeseries",
|
||||
"title": "Queue Depth & Oldest Unfinished Job Age",
|
||||
"gridPos": { "x": 16, "y": 8, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max by (state) (worker_queue_depth{queue_name=\"attachment-jobs\"})",
|
||||
"legendFormat": "depth {{state}}"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "max(worker_oldest_job_age_seconds{queue_name=\"attachment-jobs\"})",
|
||||
"legendFormat": "oldest age (s)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "timeseries",
|
||||
"title": "DB Pool Saturation (used / idle / waiting)",
|
||||
"gridPos": { "x": 0, "y": 16, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (state) (db_pool_connections)",
|
||||
"legendFormat": "pool {{state}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "timeseries",
|
||||
"title": "Worker Concurrency Saturation & Process RSS",
|
||||
"gridPos": { "x": 8, "y": 16, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max by (state) (worker_threads)",
|
||||
"legendFormat": "worker {{state}}"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "avg by (service_name) (process_memory_rss_bytes) / 1048576",
|
||||
"legendFormat": "RSS MiB {{service_name}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"type": "timeseries",
|
||||
"title": "OTel Collector Pipeline (accepted / sent / failed)",
|
||||
"gridPos": { "x": 16, "y": 16, "w": 8, "h": 8 },
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_spans_total[1m])) or sum(rate(otelcol_receiver_accepted_spans[1m]))",
|
||||
"legendFormat": "spans accepted/s"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum(rate(otelcol_exporter_sent_spans_total[1m])) or sum(rate(otelcol_exporter_sent_spans[1m]))",
|
||||
"legendFormat": "spans sent/s"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[1m])) or sum(rate(otelcol_exporter_send_failed_spans[1m]))",
|
||||
"legendFormat": "spans send_failed/s"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
apiVersion: 1
|
||||
groups:
|
||||
- orgId: 1
|
||||
name: messenger-slo-alerts
|
||||
folder: Messenger
|
||||
interval: 10s
|
||||
rules:
|
||||
- uid: messenger-high-5xx
|
||||
title: High API 5xx Error Ratio (>5%)
|
||||
condition: C
|
||||
for: 15s
|
||||
noDataState: OK
|
||||
execErrState: Error
|
||||
annotations:
|
||||
summary: High 5xx error ratio on business routes
|
||||
description: 5xx error ratio exceeded 5% over 1m window. See infra/otel/RUNBOOKS.md.
|
||||
labels:
|
||||
severity: critical
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: prometheus
|
||||
model:
|
||||
datasource:
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
expr: sum(rate(http_server_requests_total{service_name="messenger-api",http_route!~"/health/.*",http_response_status_class="5xx"}[1m])) / clamp_min(sum(rate(http_server_requests_total{service_name="messenger-api",http_route!~"/health/.*"}[1m])), 0.001)
|
||||
instant: true
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
refId: A
|
||||
- refId: B
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: __expr__
|
||||
expression: A
|
||||
reducer: last
|
||||
type: reduce
|
||||
refId: B
|
||||
- refId: C
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: __expr__
|
||||
expression: B
|
||||
type: threshold
|
||||
conditions:
|
||||
- evaluator:
|
||||
params:
|
||||
- 0.05
|
||||
type: gt
|
||||
operator:
|
||||
type: and
|
||||
query:
|
||||
params:
|
||||
- C
|
||||
reducer:
|
||||
params: []
|
||||
type: last
|
||||
type: query
|
||||
refId: C
|
||||
- uid: messenger-queue-lag
|
||||
title: Growing Attachment Queue Lag (>15s)
|
||||
condition: C
|
||||
for: 15s
|
||||
noDataState: OK
|
||||
execErrState: Error
|
||||
annotations:
|
||||
summary: Oldest unfinished attachment job age > 15s
|
||||
description: Worker stopped or overloaded. Check worker saturation and DLQ. See infra/otel/RUNBOOKS.md.
|
||||
labels:
|
||||
severity: warning
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: prometheus
|
||||
model:
|
||||
datasource:
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
expr: max(worker_oldest_job_age_seconds{queue_name="attachment-jobs"})
|
||||
instant: true
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
refId: A
|
||||
- refId: B
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: __expr__
|
||||
expression: A
|
||||
reducer: last
|
||||
type: reduce
|
||||
refId: B
|
||||
- refId: C
|
||||
relativeTimeRange:
|
||||
from: 120
|
||||
to: 0
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: __expr__
|
||||
expression: B
|
||||
type: threshold
|
||||
conditions:
|
||||
- evaluator:
|
||||
params:
|
||||
- 15
|
||||
type: gt
|
||||
operator:
|
||||
type: and
|
||||
query:
|
||||
params:
|
||||
- C
|
||||
reducer:
|
||||
params: []
|
||||
type: last
|
||||
type: query
|
||||
refId: C
|
||||
@@ -0,0 +1,11 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: Messenger
|
||||
orgId: 1
|
||||
folder: Messenger
|
||||
type: file
|
||||
disableDeletion: false
|
||||
editable: true
|
||||
updateIntervalSeconds: 10
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,41 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
jsonData:
|
||||
timeInterval: 5s
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
editable: false
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- datasourceUid: tempo
|
||||
matcherType: label
|
||||
matcherRegex: "trace_id"
|
||||
name: TraceID
|
||||
url: "$${__value.raw}"
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
editable: false
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
spanStartTimeShift: '-1m'
|
||||
spanEndTimeShift: '1m'
|
||||
filterByTraceID: true
|
||||
filterBySpanID: false
|
||||
nodeGraph:
|
||||
enabled: true
|
||||
search:
|
||||
hide: false
|
||||
@@ -0,0 +1,28 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 1024
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
timeout connect 500ms
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
timeout check 1s
|
||||
retries 0
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 2
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold obsolete 1s
|
||||
frontend public
|
||||
bind *:8080
|
||||
default_backend replicas
|
||||
backend replicas
|
||||
balance roundrobin
|
||||
option http-server-close
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server inter 1s fastinter 500ms downinter 1s fall 2 rise 1 resolvers docker init-addr none
|
||||
server-template api 8 api:8080 check
|
||||
@@ -0,0 +1,30 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
|
||||
common:
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
limits_config:
|
||||
allow_structured_metadata: true
|
||||
max_line_size: 256000
|
||||
retention_period: 168h
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
@@ -0,0 +1,24 @@
|
||||
# Runbooks для инцидентов и алертов
|
||||
|
||||
## 1. High API 5xx Error Ratio (`messenger-high-5xx`)
|
||||
- **Условие:** доля 5xx по бизнес-эндпоинтам (исключая `/health/*`) превышает 5% за 1 минуту (`for: 15s`).
|
||||
- **Шаги диагностики:**
|
||||
1. Открыть Grafana → Dashboard `MTUSI Messenger — Lab 6 Observability` → панель `API 5xx Error Ratio` и `DB Pool Saturation`.
|
||||
2. Проверить в Tempo (Explore → `{ resource.service.name = "messenger-api" && status = error }`) какой дочерний span упал или замедлился (`db.query`, `db.pool.connect`, `s3.put_staging`, `broker.ping`).
|
||||
3. Перейти по `trace_id` в Loki (`{service_name="messenger-api"} | trace_id="..."`) и проверить `error.code` / `request_id`.
|
||||
- **Действия:** проверить состояние PostgreSQL / RustFS / Redis, при блокировках БД проверить `pg_stat_activity`.
|
||||
|
||||
## 2. Growing Queue Lag (`messenger-queue-lag`)
|
||||
- **Условие:** возраст старейшей незавершённой задачи `worker_oldest_job_age_seconds > 15s` (`for: 15s`).
|
||||
- **Шаги диагностики:**
|
||||
1. Открыть панель `Queue Depth & Oldest Job Age` и `Worker Concurrency Saturation`.
|
||||
2. Если `worker_threads{state="busy"} == 0` при растущей очереди — процесс `worker` остановлен или потерял связь с брокером.
|
||||
3. Если `busy == capacity` и растёт `worker_job_duration_seconds` — нехватка CPU/конкурентности или тормозит S3/DB.
|
||||
4. Проверить логи `{service_name="messenger-worker"}` на события `worker.retry` и `worker.failed`.
|
||||
- **Действия:** запустить/восстановить `worker`, проверить `attachment-jobs-dlq`, при необходимости увеличить `WORKER_CONCURRENCY`.
|
||||
|
||||
## 3. API p95 Latency SLO Breach (`messenger-latency-slo`)
|
||||
- **Условие:** `p95` по бизнес-эндпоинтам > 0.5 с за 1 минуту (`for: 30s`).
|
||||
- **Шаги диагностики:**
|
||||
1. В Tempo найти медленные трассы (`duration > 500ms`).
|
||||
2. Отличить медленную БД (время внутри `db.query` / `db.pool.connect`) от медленного кода API (разрыв между длительностью корневого server span и дочерними зависимостями).
|
||||
@@ -0,0 +1,100 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
|
||||
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: 180
|
||||
spike_limit_mib: 40
|
||||
attributes/redact:
|
||||
actions:
|
||||
- key: http.request.header.authorization
|
||||
action: delete
|
||||
- key: db.statement
|
||||
action: delete
|
||||
tail_sampling:
|
||||
decision_wait: 2s
|
||||
num_traces: 5000
|
||||
expected_new_traces_per_sec: 100
|
||||
policies:
|
||||
- name: errors-policy
|
||||
type: status_code
|
||||
status_code:
|
||||
status_codes: [ERROR]
|
||||
- name: slow-traces-policy
|
||||
type: latency
|
||||
latency:
|
||||
threshold_ms: 100
|
||||
- name: fast-sample-policy
|
||||
type: probabilistic
|
||||
probabilistic:
|
||||
sampling_percentage: 10
|
||||
batch:
|
||||
send_batch_size: 256
|
||||
timeout: 1s
|
||||
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
metric_expiration: 5m
|
||||
otlphttp/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
tls:
|
||||
insecure: true
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 200
|
||||
otlp/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls:
|
||||
insecure: true
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 200
|
||||
|
||||
service:
|
||||
extensions: [health_check]
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/redact, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/redact, tail_sampling, batch]
|
||||
exporters: [otlp/tempo]
|
||||
@@ -0,0 +1,83 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
|
||||
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: 180
|
||||
spike_limit_mib: 40
|
||||
attributes/redact:
|
||||
actions:
|
||||
- key: http.request.header.authorization
|
||||
action: delete
|
||||
- key: db.statement
|
||||
action: delete
|
||||
batch:
|
||||
send_batch_size: 256
|
||||
timeout: 1s
|
||||
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
metric_expiration: 5m
|
||||
otlphttp/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
tls:
|
||||
insecure: true
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 200
|
||||
otlp/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls:
|
||||
insecure: true
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 15s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
queue_size: 200
|
||||
|
||||
service:
|
||||
extensions: [health_check]
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/redact, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/redact, batch]
|
||||
exporters: [otlp/tempo]
|
||||
@@ -0,0 +1,29 @@
|
||||
groups:
|
||||
- name: messenger-slo-alerts
|
||||
rules:
|
||||
- alert: HighApiErrorRatio
|
||||
expr: >
|
||||
sum(rate(http_server_requests_total{service_name="messenger-api",http_route!~"/health/.*",http_response_status_class="5xx"}[1m]))
|
||||
/ clamp_min(sum(rate(http_server_requests_total{service_name="messenger-api",http_route!~"/health/.*"}[1m])), 0.001) > 0.05
|
||||
for: 15s
|
||||
labels:
|
||||
severity: critical
|
||||
annotations:
|
||||
summary: "High API 5xx error ratio (> 5%)"
|
||||
runbook: "infra/otel/RUNBOOKS.md#1-high-api-5xx-error-ratio-messenger-high-5xx"
|
||||
- alert: GrowingQueueLag
|
||||
expr: max(worker_oldest_job_age_seconds{queue_name="attachment-jobs"}) > 15
|
||||
for: 15s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "Oldest attachment job age exceeds 15s"
|
||||
runbook: "infra/otel/RUNBOOKS.md#2-growing-queue-lag-messenger-queue-lag"
|
||||
- alert: ApiLatencySloBreach
|
||||
expr: histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name="messenger-api",http_route!~"/health/.*"}[1m]))) > 0.5
|
||||
for: 30s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "API p95 latency exceeds 500ms SLO"
|
||||
runbook: "infra/otel/RUNBOOKS.md#3-api-p95-latency-slo-breach-messenger-latency-slo"
|
||||
@@ -0,0 +1,14 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
|
||||
rule_files:
|
||||
- /etc/prometheus/alerts.yml
|
||||
|
||||
scrape_configs:
|
||||
- job_name: otel-pipeline
|
||||
static_configs:
|
||||
- targets: ['otel-collector:8889']
|
||||
- job_name: otel-collector-internal
|
||||
static_configs:
|
||||
- targets: ['otel-collector:8888']
|
||||
@@ -0,0 +1 @@
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject","s3:DeleteObject"],"Resource":["arn:aws:s3:::messenger-attachments/*"]},{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::messenger-attachments"]}]}
|
||||
@@ -0,0 +1,27 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
ingester:
|
||||
trace_idle_period: 5s
|
||||
max_block_duration: 1m
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 48h
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
local:
|
||||
path: /var/tempo/traces
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
Reference in New Issue
Block a user