Implement lab7 security and compromised worker recovery evidence
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
groups:
|
||||
- name: messenger
|
||||
rules:
|
||||
- alert: ApiHighErrorRate
|
||||
expr: >-
|
||||
sum(rate(lab_http_requests_total{status_class="5xx"}[30s])) / sum(rate(lab_http_requests_total[30s])) > 0.1
|
||||
for: 6s
|
||||
annotations:
|
||||
summary: "HTTP 5xx exceeds 10% in 30s"
|
||||
runbook: "infra/otel/runbook.md#api"
|
||||
- alert: AttachmentQueueLag
|
||||
expr: >-
|
||||
max(lab_queue_oldest_seconds{queue="attachments"}) > 8 and max(lab_queue_depth{queue="attachments"}) > 0
|
||||
for: 9s
|
||||
annotations:
|
||||
summary: "Oldest unfinished attachment exceeds eight seconds"
|
||||
runbook: "infra/otel/runbook.md#queue"
|
||||
- alert: ApiBurnFast
|
||||
expr: >-
|
||||
(sum(rate(lab_http_requests_total{status_class="5xx"}[1m])) / sum(rate(lab_http_requests_total[1m])) > 0.05) and (sum(rate(lab_http_requests_total{status_class="5xx"}[15s])) / sum(rate(lab_http_requests_total[15s])) > 0.05) and (sum(increase(lab_http_requests_total[1m])) >= 6)
|
||||
for: 9s
|
||||
annotations:
|
||||
summary: "Api burn > 5x in 1m and 15s"
|
||||
runbook: "infra/otel/runbook.md#api"
|
||||
- alert: ApiBurnSlow
|
||||
expr: >-
|
||||
(sum(rate(lab_http_requests_total{status_class="5xx"}[3m])) / sum(rate(lab_http_requests_total[3m])) > 0.02) and (sum(rate(lab_http_requests_total{status_class="5xx"}[45s])) / sum(rate(lab_http_requests_total[45s])) > 0.02) and (sum(increase(lab_http_requests_total[3m])) >= 12)
|
||||
for: 18s
|
||||
annotations:
|
||||
summary: "Api burn > 2x in 3m and 45s"
|
||||
runbook: "infra/otel/runbook.md#api"
|
||||
- alert: ReadyBurnFast
|
||||
expr: >-
|
||||
(sum(rate(lab_ready_sli_total{outcome="bad"}[1m])) / sum(rate(lab_ready_sli_total[1m])) > 0.25) and (sum(rate(lab_ready_sli_total{outcome="bad"}[15s])) / sum(rate(lab_ready_sli_total[15s])) > 0.25) and (sum(increase(lab_ready_sli_total[1m])) >= 6)
|
||||
for: 9s
|
||||
annotations:
|
||||
summary: "Ready burn > 5x in 1m and 15s"
|
||||
runbook: "infra/otel/runbook.md#queue"
|
||||
- alert: ReadyBurnSlow
|
||||
expr: >-
|
||||
(sum(rate(lab_ready_sli_total{outcome="bad"}[3m])) / sum(rate(lab_ready_sli_total[3m])) > 0.1) and (sum(rate(lab_ready_sli_total{outcome="bad"}[45s])) / sum(rate(lab_ready_sli_total[45s])) > 0.1) and (sum(increase(lab_ready_sli_total[3m])) >= 12)
|
||||
for: 18s
|
||||
annotations:
|
||||
summary: "Ready burn > 2x in 3m and 45s"
|
||||
runbook: "infra/otel/runbook.md#queue"
|
||||
@@ -0,0 +1,77 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 127.0.0.1:14318
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 128
|
||||
spike_limit_mib: 32
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 128
|
||||
send_batch_max_size: 256
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 127.0.0.1:18889
|
||||
metric_expiration: 20s
|
||||
otlp/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls: &id001
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /identity/service.crt
|
||||
key_file: /identity/service.key
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
queue_size: 32
|
||||
num_consumers: 1
|
||||
retry_on_failure:
|
||||
initial_interval: 1s
|
||||
max_interval: 3s
|
||||
max_elapsed_time: 10s
|
||||
otlphttp/loki:
|
||||
endpoint: https://loki:3100/otlp
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
queue_size: 32
|
||||
num_consumers: 1
|
||||
retry_on_failure:
|
||||
initial_interval: 1s
|
||||
max_interval: 3s
|
||||
max_elapsed_time: 10s
|
||||
tls: *id001
|
||||
service:
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 127.0.0.1
|
||||
port: 18888
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers:
|
||||
- otlp
|
||||
processors:
|
||||
- memory_limiter
|
||||
- batch
|
||||
exporters:
|
||||
- prometheus
|
||||
logs:
|
||||
receivers:
|
||||
- otlp
|
||||
processors:
|
||||
- memory_limiter
|
||||
- batch
|
||||
exporters:
|
||||
- otlphttp/loki
|
||||
traces:
|
||||
receivers:
|
||||
- otlp
|
||||
processors:
|
||||
- memory_limiter
|
||||
- batch
|
||||
exporters:
|
||||
- otlp/tempo
|
||||
@@ -0,0 +1,501 @@
|
||||
{
|
||||
"uid": "messenger-lab6",
|
||||
"title": "Messenger Lab 6",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "5s",
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API requests / second",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (status_class) (rate(lab_http_requests_total[1m]))",
|
||||
"legendFormat": "{{status_class}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API 5xx share",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "(sum(rate(lab_http_requests_total{status_class=\"5xx\"}[1m])) or vector(0)) / sum(rate(lab_http_requests_total[1m]))",
|
||||
"legendFormat": "5xx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "HTTP latency across replicas",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(lab_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(lab_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(lab_http_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Worker delivery outcomes / second",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (outcome) (rate(lab_jobs_total[1m]))",
|
||||
"legendFormat": "{{outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Worker delivery latency",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(lab_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(lab_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(lab_job_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Acceptance to READY",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(lab_ready_duration_seconds_bucket[3m])))",
|
||||
"legendFormat": "p50"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(lab_ready_duration_seconds_bucket[3m])))",
|
||||
"legendFormat": "p95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(lab_ready_duration_seconds_bucket[3m])))",
|
||||
"legendFormat": "p99"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Unfinished jobs",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(lab_queue_depth)",
|
||||
"legendFormat": "depth"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Oldest unfinished job",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(lab_queue_oldest_seconds)",
|
||||
"legendFormat": "age"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "DB pool per API",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "lab_db_pool_connections",
|
||||
"legendFormat": "{{instance}} {{state}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(lab_worker_busy) / sum(lab_worker_capacity)",
|
||||
"legendFormat": "busy/capacity"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "Process CPU",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "rate(lab_process_cpu_seconds_total[1m])",
|
||||
"legendFormat": "{{job}} {{instance}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "lab_process_rss_bytes",
|
||||
"legendFormat": "{{job}} {{instance}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "Burn rates",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(lab_http_requests_total{status_class=\"5xx\"}[1m])) / sum(rate(lab_http_requests_total[1m])) / 0.01",
|
||||
"legendFormat": "API"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum(rate(lab_ready_sli_total{outcome=\"bad\"}[1m])) / sum(rate(lab_ready_sli_total[1m])) / 0.05",
|
||||
"legendFormat": "READY"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"title": "Active alerts",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "ALERTS{alertstate=~\"pending|firing\"}",
|
||||
"legendFormat": "{{alertname}} {{alertstate}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"title": "Correlated API and worker logs",
|
||||
"type": "logs",
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=~\"messenger-(api|worker|dispatcher)\"}",
|
||||
"legendFormat": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"title": "SLO attainment over 30 minutes",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"legendFormat": "API success (target 99%)",
|
||||
"expr": "1 - (sum(increase(lab_http_requests_total{status_class=\"5xx\"}[30m])) or vector(0)) / sum(increase(lab_http_requests_total[30m]))"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"legendFormat": "READY within 5s (target 95%)",
|
||||
"expr": "sum(increase(lab_ready_sli_total{outcome=\"good\"}[30m])) / sum(increase(lab_ready_sli_total[30m]))"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: messenger
|
||||
type: file
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,45 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
url: https://prometheus:9090
|
||||
isDefault: true
|
||||
jsonData:
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
tlsSkipVerify: false
|
||||
secureJsonData:
|
||||
tlsCACert: $TLS_CA
|
||||
tlsClientCert: $TLS_CERT
|
||||
tlsClientKey: $TLS_KEY
|
||||
- name: Loki
|
||||
type: loki
|
||||
uid: loki
|
||||
url: https://loki:3100
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- name: TraceID
|
||||
matcherType: label
|
||||
matcherRegex: trace_id
|
||||
datasourceUid: tempo
|
||||
url: $${__value.raw}
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
tlsSkipVerify: false
|
||||
secureJsonData:
|
||||
tlsCACert: $TLS_CA
|
||||
tlsClientCert: $TLS_CERT
|
||||
tlsClientKey: $TLS_KEY
|
||||
- name: Tempo
|
||||
type: tempo
|
||||
uid: tempo
|
||||
url: https://tempo:3200
|
||||
jsonData:
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
tlsSkipVerify: false
|
||||
secureJsonData:
|
||||
tlsCACert: $TLS_CA
|
||||
tlsClientCert: $TLS_CERT
|
||||
tlsClientKey: $TLS_KEY
|
||||
@@ -0,0 +1,31 @@
|
||||
auth_enabled: false
|
||||
server:
|
||||
http_listen_port: 13100
|
||||
http_listen_address: 127.0.0.1
|
||||
grpc_listen_address: 127.0.0.1
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
limits_config:
|
||||
allow_structured_metadata: true
|
||||
retention_period: 24h
|
||||
compactor:
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
@@ -0,0 +1,22 @@
|
||||
global:
|
||||
scrape_interval: 3s
|
||||
evaluation_interval: 3s
|
||||
rule_files:
|
||||
- /etc/prometheus/alerts.yaml
|
||||
scrape_configs:
|
||||
- job_name: otlp
|
||||
honor_labels: true
|
||||
static_configs:
|
||||
- targets:
|
||||
- otel-collector:8889
|
||||
scheme: https
|
||||
tls_config: &id001
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /identity/service.crt
|
||||
key_file: /identity/service.key
|
||||
- job_name: collector
|
||||
static_configs:
|
||||
- targets:
|
||||
- otel-collector:8888
|
||||
scheme: https
|
||||
tls_config: *id001
|
||||
@@ -0,0 +1,22 @@
|
||||
# Диагностика учебного стенда
|
||||
|
||||
Откройте dashboard Messenger Lab 6 по адресу https://127.0.0.1:13007/d/messenger-lab6. Вход admin; пароль находится только в secrets/operator/grafana_password. Доверяйте secrets/public/ca.crt. Для определения времени инцидента используйте состояние правил Prometheus и отметки проб в evidence. Для локального запуска тестов используйте команды из REPORT.md.
|
||||
|
||||
## API
|
||||
|
||||
1. По панели API 5xx share найдите интервал деградации. Сопоставьте его с API latency и DB pool used/waiting. Проверьте наличие трафика перед интерпретацией доли ошибок.
|
||||
2. В Explore выберите Loki. Запрос `{service_name="messenger-api"} | status_class="5xx"` покажет события завершения запросов. Найдите тот же `request_id`, что в HTTP-заголовке. Временно сузьте диапазон времени, чтобы исключить ошибки предыдущего опыта.
|
||||
3. Скопируйте `trace_id` в Tempo или откройте ссылку TraceID. Длинный дочерний span `postgres.session.lookup` с ошибкой показывает, что запрос ждал PostgreSQL в ходе проверки сессии. Если задержка приходится на другое дочернее действие, смотрите его имя и статус.
|
||||
4. Снимите операторскую блокировку и проверьте, что 200 восстановились, доля 5xx снизилась и правила перешли в inactive. При необходимости проверьте состояние DB-контейнера и ожидания в `pg_stat_activity`.
|
||||
|
||||
## Queue
|
||||
|
||||
1. При росте `Oldest unfinished job` сравните backlog с активностью worker. Большой backlog при исчезновении рядов capacity означает отсутствие свежей телеметрии воркеров. Подтвердите состояние контейнеров через `docker compose ps`. Активные воркеры при высоком busy/capacity указывают на насыщение.
|
||||
2. По X-Request-Id принятого upload найдите `http.completed` в Loki. В Tempo проверьте producer `attachments publish` и consumer `attachments consume`. По `job.attempt` видно повторную обработку. Ошибки S3 и БД различаются по дочерним spans.
|
||||
3. Восстановите работу воркеров. Проверьте исчезновение backlog, переход AttachmentQueueLag в inactive и завершение ранее принятых вложений. Ready burn может сработать после обработки накопившихся медленных вложений и завершится после выхода этих наблюдений из короткого окна.
|
||||
|
||||
## Telemetry
|
||||
|
||||
1. При отсутствии логов проверьте состояние Loki и запросы через datasource. Сопоставьте с Prometheus `up` для Collector и с `otelcol_exporter_send_failed_log_records_total`.
|
||||
2. По `otelcol_exporter_queue_size` и `otelcol_exporter_queue_capacity` проверьте предел очереди. Рост ошибок экспорта после истечения retry window означает потерю наблюдений.
|
||||
3. Проверьте HTTP-запись и чтение сообщений, затем восстановите Loki и найдите свежий `http.completed` в Grafana. SDK и Collector держат ограниченные очереди в памяти.
|
||||
@@ -0,0 +1,23 @@
|
||||
server:
|
||||
http_listen_port: 13200
|
||||
http_listen_address: 127.0.0.1
|
||||
grpc_listen_address: 127.0.0.1
|
||||
grpc_listen_port: 19095
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 127.0.0.1:14317
|
||||
ingester:
|
||||
max_block_duration: 5m
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 24h
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
set -eu
|
||||
export INSTANCE_ID="$(cat /proc/sys/kernel/random/uuid)"
|
||||
printf '%s' "$INSTANCE_ID" > /tmp/instance-id
|
||||
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=lab,service.version=7.0.0,service.instance.id=$INSTANCE_ID"
|
||||
exec java -Dfile.encoding=UTF-8 ${JAVA_OPTS:-} -jar app.jar
|
||||
@@ -0,0 +1,6 @@
|
||||
storage_source "file" { path = "/old" }
|
||||
storage_destination "raft" {
|
||||
path = "/bao/file"
|
||||
node_id = "bao-1"
|
||||
}
|
||||
cluster_addr = "https://127.0.0.1:8201"
|
||||
@@ -0,0 +1,14 @@
|
||||
ui = true
|
||||
storage "raft" {
|
||||
path = "/bao/file"
|
||||
node_id = "bao-1"
|
||||
}
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
tls_cert_file = "/identity/service.crt"
|
||||
tls_key_file = "/identity/service.key"
|
||||
tls_client_ca_file = "/pki/ca.crt"
|
||||
}
|
||||
api_addr = "https://openbao:8200"
|
||||
|
||||
cluster_addr = "https://openbao:8201"
|
||||
@@ -0,0 +1,42 @@
|
||||
pid /tmp/nginx.pid;
|
||||
worker_shutdown_timeout 5s;
|
||||
error_log /dev/stderr warn;
|
||||
events { worker_connections 1024; }
|
||||
http { access_log off; client_body_temp_path /tmp/body; proxy_temp_path /tmp/proxy; client_max_body_size 11m; ssl_certificate /identity/service.crt; ssl_certificate_key /identity/service.key; ssl_client_certificate /pki/ca.crt; ssl_crl /pki/ca.crl; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_tickets off; ssl_session_cache off; server { listen 3000 ssl; location / { proxy_pass http://127.0.0.1:13000; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto https; } }
|
||||
map $ssl_client_s_dn $allowed_4318 { default 0; CN=api 1; CN=worker 1; CN=dispatcher 1; }
|
||||
server { listen 4318 ssl; ssl_verify_client on;
|
||||
location / { if ($allowed_4318 = 0) { return 403; } proxy_pass http://127.0.0.1:14318; proxy_http_version 1.1; }
|
||||
}
|
||||
map $ssl_client_s_dn $allowed_8888 { default 0; CN=prometheus 1; }
|
||||
server { listen 8888 ssl; ssl_verify_client on;
|
||||
location / { if ($allowed_8888 = 0) { return 403; } proxy_pass http://127.0.0.1:18888; proxy_http_version 1.1; }
|
||||
}
|
||||
map $ssl_client_s_dn $allowed_8889 { default 0; CN=prometheus 1; }
|
||||
server { listen 8889 ssl; ssl_verify_client on;
|
||||
location / { if ($allowed_8889 = 0) { return 403; } proxy_pass http://127.0.0.1:18889; proxy_http_version 1.1; }
|
||||
}
|
||||
map $ssl_client_s_dn $allowed_9090 { default 0; CN=grafana 1; CN=operator 1; }
|
||||
server { listen 9090 ssl; ssl_verify_client on;
|
||||
location / { if ($allowed_9090 = 0) { return 403; } proxy_pass http://127.0.0.1:19090; proxy_http_version 1.1; }
|
||||
}
|
||||
map "$ssl_client_s_dn:$request_method:$uri" $loki_action {
|
||||
default 0;
|
||||
~^CN=collector:POST:/otlp/v1/logs$ 1;
|
||||
~^CN=(grafana|operator):GET:/(loki/api/v1/|ready) 1;
|
||||
}
|
||||
map $ssl_client_s_dn $allowed_3100 { default 0; CN=collector 1; CN=grafana 1; CN=operator 1; }
|
||||
server { listen 3100 ssl; ssl_verify_client on;
|
||||
location / { if ($loki_action = 0) { return 403; } proxy_pass http://127.0.0.1:13100; proxy_http_version 1.1; }
|
||||
}
|
||||
map $ssl_client_s_dn $allowed_3200 { default 0; CN=grafana 1; CN=operator 1; }
|
||||
server { listen 3200 ssl; ssl_verify_client on;
|
||||
location / { if ($request_method != GET) { return 403; } if ($allowed_3200 = 0) { return 403; } proxy_pass http://127.0.0.1:13200; proxy_http_version 1.1; }
|
||||
}
|
||||
}
|
||||
stream { ssl_certificate /identity/service.crt; ssl_certificate_key /identity/service.key; ssl_client_certificate /pki/ca.crt; ssl_crl /pki/ca.crl; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_tickets off; ssl_session_cache off; map $ssl_client_s_dn $target_6379 { default 127.0.0.1:9; CN=worker 127.0.0.1:16379; CN=dispatcher 127.0.0.1:16379; CN=api 127.0.0.1:16379; CN=operator 127.0.0.1:16379; }
|
||||
server { listen 6379 ssl; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_6379; }
|
||||
map $ssl_client_s_dn $target_6380 { default 127.0.0.1:9; CN=api 127.0.0.1:16380; CN=operator 127.0.0.1:16380; }
|
||||
server { listen 6380 ssl; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_6380; }
|
||||
map $ssl_client_s_dn $target_4317 { default 127.0.0.1:9; CN=collector 127.0.0.1:14317; }
|
||||
server { listen 4317 ssl; ssl_alpn h2; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_4317; }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
set -eu
|
||||
export TLS_CA="$(cat /pki/ca.crt)"
|
||||
export TLS_CERT="$(cat /identity/service.crt)"
|
||||
export TLS_KEY="$(cat /identity/service.key)"
|
||||
exec /run.sh
|
||||
@@ -0,0 +1,3 @@
|
||||
local all all trust
|
||||
hostssl messenger api,worker,dispatcher,pipeline_operator all scram-sha-256
|
||||
host all all all reject
|
||||
@@ -0,0 +1 @@
|
||||
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:GetObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
@@ -0,0 +1,2 @@
|
||||
path "secret/data/api" { capabilities = ["read"] }
|
||||
path "auth/token/revoke-self" { capabilities = ["update"] }
|
||||
@@ -0,0 +1 @@
|
||||
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
@@ -0,0 +1,2 @@
|
||||
path "secret/data/dispatcher" { capabilities = ["read"] }
|
||||
path "auth/token/revoke-self" { capabilities = ["update"] }
|
||||
@@ -0,0 +1 @@
|
||||
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:GetObject", "s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
@@ -0,0 +1,2 @@
|
||||
path "secret/data/worker" { capabilities = ["read"] }
|
||||
path "auth/token/revoke-self" { capabilities = ["update"] }
|
||||
@@ -0,0 +1,7 @@
|
||||
set -eu
|
||||
mkdir -p /tmp/pg-tls
|
||||
cp /identity/service.crt /tmp/pg-tls/server.crt
|
||||
cp /identity/service.key /tmp/pg-tls/server.key
|
||||
chown -R postgres:postgres /tmp/pg-tls
|
||||
chmod 600 /tmp/pg-tls/server.key
|
||||
exec /usr/local/bin/docker-entrypoint.sh "$@"
|
||||
Reference in New Issue
Block a user