lab6: observability — OTel Collector, Prometheus, Loki, Tempo, Grafana
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout connect 2s
|
||||
timeout client 10s
|
||||
timeout server 10s
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 5s
|
||||
|
||||
frontend http_front
|
||||
bind *:8080
|
||||
default_backend api_backend
|
||||
|
||||
backend api_backend
|
||||
balance roundrobin
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/live
|
||||
http-check expect status 200
|
||||
server-template api 1-10 api:8080 check resolvers docker init-addr libc
|
||||
@@ -0,0 +1,64 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 256
|
||||
spike_limit_mib: 64
|
||||
batch:
|
||||
send_batch_size: 512
|
||||
send_batch_max_size: 1024
|
||||
timeout: 5s
|
||||
|
||||
exporters:
|
||||
otlphttp/tempo:
|
||||
endpoint: http://tempo:4318
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
prometheusremotewrite:
|
||||
endpoint: http://prometheus:9090/api/v1/write
|
||||
tls:
|
||||
insecure: true
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 10s
|
||||
max_elapsed_time: 60s
|
||||
|
||||
otlphttp/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
service:
|
||||
telemetry:
|
||||
logs:
|
||||
level: info
|
||||
metrics:
|
||||
level: detailed
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheusremotewrite]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"annotations": { "list": [] },
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 1,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "reqps", "color": { "mode": "palette-classic" } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 6, "x": 0, "y": 0 },
|
||||
"id": 1,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(http_requests_total[1m]))",
|
||||
"legendFormat": "all",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "sum by (status_class) (rate(http_requests_total[1m]))",
|
||||
"legendFormat": "{{status_class}}",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"title": "HTTP RPS (by status_class)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit",
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"thresholds": { "mode": "absolute", "steps": [
|
||||
{ "color": "green", "value": null },
|
||||
{ "color": "yellow", "value": 0.01 },
|
||||
{ "color": "red", "value": 0.05 }
|
||||
] }
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": { "h": 8, "w": 6, "x": 6, "y": 0 },
|
||||
"id": 2,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "reduceOptions": { "calcs": ["lastNotNull"] } },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(http_requests_total{status_class=\"5xx\"}[5m])) / sum(rate(http_requests_total[5m]))",
|
||||
"legendFormat": "5xx ratio",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "HTTP 5xx ratio",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line", "fillOpacity": 10 } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
|
||||
"id": 3,
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["p50","p95","p99","max"] } },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95",
|
||||
"refId": "B"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C"
|
||||
}
|
||||
],
|
||||
"title": "HTTP latency p50/p95/p99 (all routes)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line", "fillOpacity": 10 } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
|
||||
"id": 4,
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["p95","p99"] } },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, sum by (le, route) (rate(http_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95 {{route}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "HTTP p95 by route",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 6, "x": 12, "y": 8 },
|
||||
"id": 5,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "db_pool_used", "legendFormat": "used {{instance}}", "refId": "A" },
|
||||
{ "expr": "db_pool_available", "legendFormat": "available {{instance}}", "refId": "B" },
|
||||
{ "expr": "db_pool_waiting", "legendFormat": "waiting {{instance}}", "refId": "C" }
|
||||
],
|
||||
"title": "DB pool",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 6, "x": 18, "y": 8 },
|
||||
"id": 6,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "sum by (route) (rate(http_requests_total{status_class=~\"4xx|5xx\"}[5m]))", "legendFormat": "{{route}}", "refId": "A" }
|
||||
],
|
||||
"title": "Error requests/s by route",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 39,
|
||||
"tags": ["messenger", "lab6", "api"],
|
||||
"templating": { "list": [] },
|
||||
"time": { "from": "now-15m", "to": "now" },
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "Messenger API Overview",
|
||||
"uid": "messenger-api-overview",
|
||||
"version": 1,
|
||||
"weekStart": ""
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"annotations": { "list": [] },
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 1,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "reqps", "color": { "mode": "palette-classic" } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 0 },
|
||||
"id": 1,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "sum by (outcome) (rate(jobs_processed_total[1m]))", "legendFormat": "{{outcome}}", "refId": "A" }
|
||||
],
|
||||
"title": "Jobs processed/s by outcome",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line", "fillOpacity": 10 } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 0 },
|
||||
"id": 2,
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["p50","p95","p99","max"] } },
|
||||
"targets": [
|
||||
{ "expr": "histogram_quantile(0.50, sum by (le) (rate(job_processing_duration_seconds_bucket[5m])))", "legendFormat": "p50", "refId": "A" },
|
||||
{ "expr": "histogram_quantile(0.95, sum by (le) (rate(job_processing_duration_seconds_bucket[5m])))", "legendFormat": "p95", "refId": "B" },
|
||||
{ "expr": "histogram_quantile(0.99, sum by (le) (rate(job_processing_duration_seconds_bucket[5m])))", "legendFormat": "p99", "refId": "C" }
|
||||
],
|
||||
"title": "Job duration p50/p95/p99",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [
|
||||
{ "color": "green", "value": null },
|
||||
{ "color": "yellow", "value": 10 },
|
||||
{ "color": "red", "value": 100 }
|
||||
] } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 0 },
|
||||
"id": 3,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "reduceOptions": { "calcs": ["lastNotNull"] } },
|
||||
"targets": [
|
||||
{ "expr": "rabbitmq_queue_messages{queue=\"attachment.process.v1\"}", "legendFormat": "queue depth", "refId": "A" },
|
||||
{ "expr": "jobs_pending_count", "legendFormat": "pending (outbox)", "refId": "B" },
|
||||
{ "expr": "jobs_processing_count", "legendFormat": "processing (leased)", "refId": "C" }
|
||||
],
|
||||
"title": "Queue depth / pending / processing",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [
|
||||
{ "color": "green", "value": null },
|
||||
{ "color": "yellow", "value": 30 },
|
||||
{ "color": "red", "value": 60 }
|
||||
] } }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 8 },
|
||||
"id": 4,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "jobs_oldest_pending_age_seconds", "legendFormat": "oldest pending", "refId": "A" }
|
||||
],
|
||||
"title": "Oldest pending job age (s)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 8 },
|
||||
"id": 5,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "worker_in_flight", "legendFormat": "in_flight", "refId": "A" },
|
||||
{ "expr": "worker_capacity", "legendFormat": "capacity", "refId": "B" }
|
||||
],
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"fieldConfig": { "defaults": { "unit": "reqps" }, "overrides": [] },
|
||||
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 8 },
|
||||
"id": 6,
|
||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" } },
|
||||
"targets": [
|
||||
{ "expr": "sum by (job_type) (rate(jobs_processed_total{outcome=\"failure\"}[5m]))", "legendFormat": "failed {{job_type}}", "refId": "A" }
|
||||
],
|
||||
"title": "Failed jobs/s",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 39,
|
||||
"tags": ["messenger", "lab6", "worker"],
|
||||
"templating": { "list": [] },
|
||||
"time": { "from": "now-15m", "to": "now" },
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "Messenger Worker Pipeline",
|
||||
"uid": "messenger-worker-pipeline",
|
||||
"version": 1,
|
||||
"weekStart": ""
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: "messenger-lab6"
|
||||
orgId: 1
|
||||
folder: "Messenger"
|
||||
type: file
|
||||
disableDeletion: false
|
||||
updateIntervalSeconds: 30
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,37 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
uid: prometheus
|
||||
|
||||
- name: Loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
editable: false
|
||||
uid: loki
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- datasourceUid: tempo
|
||||
matcherRegex: '"trace_id":"([a-f0-9]+)"'
|
||||
name: TraceID
|
||||
url: "$${__value.raw}"
|
||||
|
||||
- name: Tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
editable: false
|
||||
uid: tempo
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
filterByTraceID: true
|
||||
filterBySpanID: false
|
||||
serviceMap:
|
||||
datasourceUid: prometheus
|
||||
@@ -0,0 +1,45 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
log_level: info
|
||||
|
||||
common:
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
instance_addr: 127.0.0.1
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
limits_config:
|
||||
retention_period: 168h # 7 дней
|
||||
allow_structured_metadata: true
|
||||
otlp_config:
|
||||
resource_attributes:
|
||||
attributes_config:
|
||||
- action: index_label
|
||||
attributes:
|
||||
- service.name
|
||||
- service.namespace
|
||||
- deployment.environment.name
|
||||
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
@@ -0,0 +1,43 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
cluster: mtusi-lab6
|
||||
|
||||
rule_files:
|
||||
- /etc/prometheus/rules/*.yml
|
||||
|
||||
scrape_configs:
|
||||
- job_name: prometheus
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
|
||||
- job_name: otel-collector
|
||||
static_configs:
|
||||
- targets: ["otel-collector:8888"]
|
||||
|
||||
# API — обе реплики (хардкод имён контейнеров; в compose алиасы сервисов
|
||||
# не работают для обеих реплик одновременно через DNS SD)
|
||||
- job_name: api
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets:
|
||||
- "mtusi2026lab6-api-1:8080"
|
||||
- "mtusi2026lab6-api-2:8080"
|
||||
labels:
|
||||
service: api
|
||||
|
||||
- job_name: worker
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["worker:9100"]
|
||||
|
||||
- job_name: relay
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["relay:9101"]
|
||||
|
||||
- job_name: rabbitmq
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["broker:15692"]
|
||||
@@ -0,0 +1,33 @@
|
||||
groups:
|
||||
- name: api
|
||||
interval: 30s
|
||||
rules:
|
||||
- alert: HighErrorRate
|
||||
expr: |
|
||||
(
|
||||
sum(rate(http_requests_total{status_class="5xx"}[5m]))
|
||||
/
|
||||
sum(rate(http_requests_total[5m]))
|
||||
) > 0.05
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
component: api
|
||||
annotations:
|
||||
summary: "API 5xx ratio > 5% for 2m"
|
||||
description: "Current 5xx ratio: {{ $value | humanizePercentage }}"
|
||||
runbook: "infra/otel/runbooks/high-error-rate.md"
|
||||
|
||||
- alert: HighLatency
|
||||
expr: |
|
||||
histogram_quantile(
|
||||
0.95,
|
||||
sum(rate(http_request_duration_seconds_bucket[5m])) by (le)
|
||||
) > 2.0
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
component: api
|
||||
annotations:
|
||||
summary: "API p95 latency > 2s for 5m"
|
||||
description: "p95 latency: {{ $value | humanizeDuration }}"
|
||||
@@ -0,0 +1,26 @@
|
||||
groups:
|
||||
- name: worker
|
||||
interval: 30s
|
||||
rules:
|
||||
- alert: QueueLagHigh
|
||||
expr: |
|
||||
jobs_oldest_pending_age_seconds > 60
|
||||
for: 2m
|
||||
labels:
|
||||
severity: critical
|
||||
component: worker
|
||||
annotations:
|
||||
summary: "Oldest pending job age > 60s for 2m"
|
||||
description: "Oldest pending job: {{ $value | humanizeDuration }}"
|
||||
runbook: "infra/otel/runbooks/queue-lag.md"
|
||||
|
||||
- alert: WorkerSaturated
|
||||
expr: |
|
||||
worker_in_flight >= worker_capacity
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
component: worker
|
||||
annotations:
|
||||
summary: "Worker at capacity for 5m"
|
||||
description: "in_flight={{ $value }}"
|
||||
@@ -0,0 +1,20 @@
|
||||
# HighErrorRate runbook
|
||||
|
||||
## Symptom
|
||||
Prometheus alert `HighErrorRate`: 5xx ratio > 5% за 2 минуты.
|
||||
|
||||
## Diagnose
|
||||
1. Открой Grafana → Messenger / API Overview. Найди график `HTTP requests by status_class`. Посмотри, какая `route` даёт 5xx.
|
||||
2. В Loki запроси: `{service_name="messenger-api"} | json | severity="ERROR"`.
|
||||
3. Возьми `trace_id` из лога → открой в Tempo. Проверь span, где произошёл exception (`status.code = ERROR`).
|
||||
4. Если в трейсе видно `db.query` со status ERROR и `PoolTimeout` → см. `db-pool-exhausted.md` (TODO).
|
||||
5. Если `job.publish` со status ERROR и `broker unavailable` → проверь broker: `docker compose ps broker`.
|
||||
|
||||
## Remediate
|
||||
- Перезапустить API: `docker compose restart api`
|
||||
- Если причина в БД: проверить `pg_stat_activity`, `docker compose logs postgres`
|
||||
- Если причина в broker: `docker compose restart broker relay`
|
||||
|
||||
## Prevent
|
||||
- Настроить retry на DB pool (psycopg_pool `timeout`).
|
||||
- Расширить pool (`max_size`).
|
||||
@@ -0,0 +1,20 @@
|
||||
# QueueLagHigh runbook
|
||||
|
||||
## Symptom
|
||||
Prometheus alert `QueueLagHigh`: `jobs_oldest_pending_age_seconds > 60` за 2 минуты.
|
||||
|
||||
## Diagnose
|
||||
1. Grafana → Messenger / Worker Pipeline. График `jobs_oldest_pending_age_seconds`. Смотрим, растёт ли — если растёт, worker не справляется.
|
||||
2. Проверить `worker_in_flight` vs `worker_capacity`. Если `in_flight == capacity` долго — worker saturated.
|
||||
3. Проверить `jobs_pending_count`, `jobs_processing_count`, `rabbitmq_queue_messages{queue="attachment.process.v1"}`.
|
||||
4. Логи worker: `{service_name="messenger-worker"} | json | severity="ERROR"`. Если видишь `job <id> attempt N failed` — смотрим exception.
|
||||
5. Логи relay: `{service_name="messenger-relay"} | json`. Если `publish failed` — проблема с broker.
|
||||
|
||||
## Remediate
|
||||
- Если worker упал: `docker compose up -d worker`. Если упал и не поднимается — `docker compose logs worker`.
|
||||
- Если relay не публикует: `docker compose logs relay`.
|
||||
- Если broker переполнен: расширить `WORKER_CONCURRENCY` или добавить реплик worker.
|
||||
|
||||
## Prevent
|
||||
- Horizontal scaling worker.
|
||||
- Более агрессивный `WORKER_CONCURRENCY`.
|
||||
@@ -0,0 +1,24 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
grpc_listen_port: 9095
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
local:
|
||||
path: /var/tempo/traces
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 24h
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:PutObject",
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:HeadBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user