Implement lab7 mTLS, scoped OpenBao secrets and worker compromise experiment

This commit is contained in:
2026-11-13 01:12:35 +03:00
parent 20afc2c790
commit 46806a5c37
120 changed files with 10228 additions and 74 deletions
+16 -4
View File
@@ -1,7 +1,19 @@
# Инфраструктура студента
# Infrastructure ЛР7
Здесь разместите конфигурации выбранных сервисов; основную топологию — в корневом compose.yaml/stack.yaml. `compose.example.yaml` — только worksheet ролей и намеренно не запускается. `contracts/infrastructure.json` задаёт минимальные роли, не готовые образы/пароли.
Исполняемый стенд: ../compose.yaml. Полная инструкция: ../REPORT.md.
Все versions закреплены digest. Подготовка: `python scripts/up.py` из корня.
В REPORT.md сопоставьте роль → service name → версия/digest → health/readiness → volume → сеть/порт → способ передачи credentials. Приведите bootstrap (schema, bucket, broker topology, а с lab6 provisioning) и безопасное повторение этих команд.
- api1/api2 — non-root ASGI + cert-auth secret supervisor, public LB только HTTPS8443.
- *-tls — отдельные identities, mTLS SAN allowlist, CA+CRL; shared namespace с backend.
- db — PostgreSQL/SCRAM, named pgdata, операторские migrations/GRANT.
- cache/broker — разные Valkey ACL/configs; persistent AOF только у broker.
- s3 — private SeaweedFS bucket, раздельные SigV4 users/prefix ACL, named s3data.
- openbao — native TLS+client verification, persistent raft, declarative audit.
- telemetry — Collector/Prometheus/Loki/Tempo/Grafana, persistent backend volumes.
- secret-init/telemetry-init/storage-init — ограниченные операторские bootstrap jobs.
Приложение строится из исходников. Не используйте заранее существующий образ преподавательского сервера вместо своей реализации. Restart hook перезапускает все соответствующие stores с volumes; failover hook останавливает только заданную API-реплику.
Матрица соединений: ../contracts/trust-matrix.md. Native plaintext listener
закрыт на loopback, TLS hop существует на каждом межконтейнерном соединении.
`docker compose restart api1` отдельно от sidecar не является штатным workflow:
используйте scripts/restart.py для согласованного stop/start shared namespaces.
Volume deletion не входит ни в запуск, ни в тесты.
+31
View File
@@ -0,0 +1,31 @@
groups:
- name: messenger-slo
interval: 5s
rules:
- alert: APIAvailabilityBurn
expr: |
(sum(rate(http_server_requests_total{status_class="5xx"}[20s])) / clamp_min(sum(rate(http_server_requests_total[20s])), 0.001) / 0.005 > 10)
and
(sum(rate(http_server_requests_total{status_class="5xx"}[60s])) / clamp_min(sum(rate(http_server_requests_total[60s])), 0.001) / 0.005 > 10)
for: 30s
labels: {severity: critical}
annotations:
summary: "API 99.5% availability budget burns >10x in both 20s and 60s windows"
runbook: "RUNBOOK.md#api"
- alert: AttachmentReadyBurn
expr: |
(sum(attachment_slo_bad{window="60"}) / clamp_min(sum(attachment_slo_eligible{window="60"}),1) / 0.01 > 10)
and
(sum(attachment_slo_bad{window="300"}) / clamp_min(sum(attachment_slo_eligible{window="300"}),1) / 0.01 > 10)
for: 15s
labels: {severity: critical}
annotations:
summary: "99% ready within 30s budget burns >10x in both 60s and 300s eligible cohorts"
runbook: "RUNBOOK.md#queue"
- alert: QueueLag
expr: max(queue_oldest_age_seconds) > 30 and sum(queue_depth) > 0
for: 10s
labels: {severity: warning}
annotations:
summary: "An unfinished durable job has waited over 30s"
runbook: "RUNBOOK.md#queue"
+669
View File
@@ -0,0 +1,669 @@
{
"uid": "mtusi-messenger",
"title": "MTUSI Messenger - signals and SLO",
"schemaVersion": 39,
"version": 1,
"editable": false,
"timezone": "browser",
"time": {
"from": "now-15m",
"to": "now"
},
"refresh": "15s",
"tags": [
"mtusi",
"lab6"
],
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "API requests / second",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum by(method,route)(rate(http_server_requests_total[1m]))",
"legendFormat": "{{method}} {{route}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 2,
"type": "timeseries",
"title": "API 5xx / all business requests",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "(sum(rate(http_server_requests_total{status_class=\"5xx\"}[1m])) or vector(0)) / clamp_min(sum(rate(http_server_requests_total[1m])),0.001)",
"legendFormat": "5xx fraction"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"min": 0,
"max": 1
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 3,
"type": "timeseries",
"title": "API latency: aggregate buckets across replicas",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.5,sum by(le)(rate(http_server_duration_seconds_bucket[1m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95,sum by(le)(rate(http_server_duration_seconds_bucket[1m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99,sum by(le)(rate(http_server_duration_seconds_bucket[1m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 4,
"type": "timeseries",
"title": "Jobs / second by outcome",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum by(outcome)(rate(jobs_processed_total[1m]))",
"legendFormat": "{{outcome}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 5,
"type": "timeseries",
"title": "Worker processing latency",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.5,sum by(le)(rate(job_processing_duration_seconds_bucket[1m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95,sum by(le)(rate(job_processing_duration_seconds_bucket[1m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99,sum by(le)(rate(job_processing_duration_seconds_bucket[1m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 6,
"type": "timeseries",
"title": "Acceptance to ready latency",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.5,sum by(le)(rate(attachment_time_to_ready_seconds_bucket[5m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95,sum by(le)(rate(attachment_time_to_ready_seconds_bucket[5m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99,sum by(le)(rate(attachment_time_to_ready_seconds_bucket[5m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 7,
"type": "timeseries",
"title": "Unfinished durable jobs",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(queue_depth)",
"legendFormat": "queue depth"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 8,
"type": "timeseries",
"title": "Oldest unfinished job age",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 24,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "max(queue_oldest_age_seconds)",
"legendFormat": "oldest"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 9,
"type": "timeseries",
"title": "DB pool",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 32,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "db_pool_used",
"legendFormat": "used {{process_instance}}"
},
{
"refId": "B",
"expr": "db_pool_waiting",
"legendFormat": "waiting {{process_instance}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 10,
"type": "timeseries",
"title": "Worker saturation",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 32,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(worker_busy) / clamp_min(sum(worker_capacity),1)",
"legendFormat": "busy / capacity"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"min": 0,
"max": 1
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 11,
"type": "timeseries",
"title": "Current process RSS",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 40,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "process_rss_bytes",
"legendFormat": "{{service}} {{process_instance}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 12,
"type": "timeseries",
"title": "Process CPU seconds / wall second",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 40,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "clamp_min(deriv(process_cpu_time_seconds[1m]),0)",
"legendFormat": "{{service}} {{process_instance}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 13,
"type": "timeseries",
"title": "API availability burn rate; budget 0.5%",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 48,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "(sum(rate(http_server_requests_total{status_class=\"5xx\"}[20s])) or vector(0)) / clamp_min(sum(rate(http_server_requests_total[20s])),0.001) / 0.005",
"legendFormat": "20s"
},
{
"refId": "B",
"expr": "(sum(rate(http_server_requests_total{status_class=\"5xx\"}[60s])) or vector(0)) / clamp_min(sum(rate(http_server_requests_total[60s])),0.001) / 0.005",
"legendFormat": "60s"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 14,
"type": "timeseries",
"title": "Ready <=30s burn rate; budget 1%",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 48,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "sum(attachment_slo_bad{window=\"60\"}) / clamp_min(sum(attachment_slo_eligible{window=\"60\"}),1) / 0.01",
"legendFormat": "60s eligible cohort"
},
{
"refId": "B",
"expr": "sum(attachment_slo_bad{window=\"300\"}) / clamp_min(sum(attachment_slo_eligible{window=\"300\"}),1) / 0.01",
"legendFormat": "300s eligible cohort"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 15,
"type": "timeseries",
"title": "Collector exporter queue / capacity",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 56,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "otelcol_exporter_queue_size",
"legendFormat": "{{exporter}} size"
},
{
"refId": "B",
"expr": "otelcol_exporter_queue_capacity",
"legendFormat": "{{exporter}} capacity"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 16,
"type": "timeseries",
"title": "Collector failed exports",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 56,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"expr": "rate(otelcol_exporter_send_failed_spans_total[1m])",
"legendFormat": "{{exporter}} spans"
},
{
"refId": "B",
"expr": "rate(otelcol_exporter_send_failed_log_records_total[1m])",
"legendFormat": "{{exporter}} logs"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 99,
"type": "logs",
"title": "Structured application logs; TraceID links to Tempo",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 64,
"w": 24,
"h": 10
},
"targets": [
{
"refId": "A",
"expr": "{service_name=~\"messenger-(api|worker|dispatcher)\"}"
}
],
"options": {
"showTime": true,
"showLabels": false,
"wrapLogMessage": true,
"sortOrder": "Descending"
}
}
],
"annotations": {
"list": []
},
"templating": {
"list": []
}
}
@@ -0,0 +1,9 @@
apiVersion: 1
providers:
- name: Messenger
folder: MTUSI
type: file
disableDeletion: true
updateIntervalSeconds: 30
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,31 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://127.0.0.1:19090
isDefault: true
- name: Loki
uid: loki
type: loki
access: proxy
url: http://127.0.0.1:13100
jsonData:
derivedFields:
- name: TraceID
matcherRegex: '"trace_id": "([0-9a-f]{32})"'
datasourceUid: tempo
url: '$${__value.raw}'
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: http://127.0.0.1:13200
jsonData:
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: '-1m'
spanEndTimeShift: '1m'
filterByTraceID: true
nodeGraph: {enabled: true}
+32
View File
@@ -0,0 +1,32 @@
global
log stdout format raw local0
maxconn 256
defaults
mode http
log global
timeout connect 1s
timeout client 35s
timeout server 32s
timeout check 1s
timeout queue 2s
retries 0
option http-server-close
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 1s
hold obsolete 1s
hold nx 1s
hold timeout 1s
frontend public
bind :8443 ssl crt /identity/combined.pem ssl-min-ver TLSv1.2
default_backend api
backend api
balance roundrobin
option log-health-checks
option httpchk GET /health/ready
http-check expect status 200
server api1 api1:8443 ssl verify required ca-file /trust/ca.crt crl-file /trust/revocations.pem crt /identity/combined.pem verifyhost api1 sni str(api1) check-sni api1 check inter 1s resolvers docker init-addr none
server api2 api2:8443 ssl verify required ca-file /trust/ca.crt crl-file /trust/revocations.pem crt /identity/combined.pem verifyhost api2 sni str(api2) check-sni api2 check inter 1s resolvers docker init-addr none
+36
View File
@@ -0,0 +1,36 @@
auth_enabled: false
server:
http_listen_address: 127.0.0.1
grpc_listen_address: 127.0.0.1
http_listen_port: 3100
common:
instance_addr: 127.0.0.1
path_prefix: /var/loki
replication_factor: 1
ring:
kvstore:
store: inmemory
storage:
filesystem:
chunks_directory: /var/loki/chunks
rules_directory: /var/loki/rules
schema_config:
configs:
- from: 2026-01-01
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
limits_config:
allow_structured_metadata: true
retention_period: 24h
ingestion_rate_mb: 2
ingestion_burst_size_mb: 4
compactor:
working_directory: /var/loki/compactor
retention_enabled: true
delete_request_store: filesystem
analytics:
reporting_enabled: false
+34
View File
@@ -0,0 +1,34 @@
[
{
"mode": "server",
"listen": 8443,
"target": 8080,
"allow": [
"lb"
]
},
{
"mode": "client",
"listen": 5432,
"host": "db",
"target": 8443
},
{
"mode": "client",
"listen": 8333,
"host": "s3",
"target": 8443
},
{
"mode": "client",
"listen": 4318,
"host": "otel-collector",
"target": 8443
},
{
"mode": "client",
"listen": 6379,
"host": "cache",
"target": 8443
}
]
+34
View File
@@ -0,0 +1,34 @@
[
{
"mode": "server",
"listen": 8443,
"target": 8080,
"allow": [
"lb"
]
},
{
"mode": "client",
"listen": 5432,
"host": "db",
"target": 8443
},
{
"mode": "client",
"listen": 8333,
"host": "s3",
"target": 8443
},
{
"mode": "client",
"listen": 4318,
"host": "otel-collector",
"target": 8443
},
{
"mode": "client",
"listen": 6379,
"host": "cache",
"target": 8443
}
]
+12
View File
@@ -0,0 +1,12 @@
[
{
"mode": "server",
"listen": 8443,
"target": 6379,
"allow": [
"worker",
"dispatcher",
"operator"
]
}
]
+12
View File
@@ -0,0 +1,12 @@
[
{
"mode": "server",
"listen": 8443,
"target": 6379,
"allow": [
"api1",
"api2",
"operator"
]
}
]
+15
View File
@@ -0,0 +1,15 @@
[
{
"mode": "server",
"listen": 8443,
"target": 5432,
"allow": [
"api1",
"api2",
"worker",
"dispatcher",
"reconciler",
"operator"
]
}
]
+20
View File
@@ -0,0 +1,20 @@
[
{
"mode": "client",
"listen": 5432,
"host": "db",
"target": 8443
},
{
"mode": "client",
"listen": 4318,
"host": "otel-collector",
"target": 8443
},
{
"mode": "client",
"listen": 6380,
"host": "broker",
"target": 8443
}
]
+20
View File
@@ -0,0 +1,20 @@
[
{
"mode": "client",
"listen": 19090,
"host": "prometheus",
"target": 8443
},
{
"mode": "client",
"listen": 13100,
"host": "loki",
"target": 8443
},
{
"mode": "client",
"listen": 13200,
"host": "tempo",
"target": 8444
}
]
+12
View File
@@ -0,0 +1,12 @@
[
{
"mode": "server",
"listen": 8443,
"target": 3100,
"allow": [
"otel-collector",
"grafana",
"operator"
]
}
]
+45
View File
@@ -0,0 +1,45 @@
[
{
"mode": "server",
"listen": 8443,
"target": 4318,
"allow": [
"api1",
"api2",
"worker",
"dispatcher",
"reconciler",
"operator"
]
},
{
"mode": "server",
"listen": 8444,
"target": 9464,
"allow": [
"prometheus",
"operator"
]
},
{
"mode": "server",
"listen": 8445,
"target": 8888,
"allow": [
"prometheus",
"operator"
]
},
{
"mode": "client",
"listen": 14318,
"host": "tempo",
"target": 8443
},
{
"mode": "client",
"listen": 13100,
"host": "loki",
"target": 8443
}
]
+23
View File
@@ -0,0 +1,23 @@
[
{
"mode": "server",
"listen": 8443,
"target": 9090,
"allow": [
"grafana",
"operator"
]
},
{
"mode": "client",
"listen": 19464,
"host": "otel-collector",
"target": 8444
},
{
"mode": "client",
"listen": 18888,
"host": "otel-collector",
"target": 8445
}
]
+20
View File
@@ -0,0 +1,20 @@
[
{
"mode": "client",
"listen": 5432,
"host": "db",
"target": 8443
},
{
"mode": "client",
"listen": 8333,
"host": "s3",
"target": 8443
},
{
"mode": "client",
"listen": 4318,
"host": "otel-collector",
"target": 8443
}
]
+14
View File
@@ -0,0 +1,14 @@
[
{
"mode": "server",
"listen": 8443,
"target": 8333,
"allow": [
"api1",
"api2",
"worker",
"reconciler",
"operator"
]
}
]
+19
View File
@@ -0,0 +1,19 @@
[
{
"mode": "server",
"listen": 8443,
"target": 4318,
"allow": [
"otel-collector"
]
},
{
"mode": "server",
"listen": 8444,
"target": 3200,
"allow": [
"grafana",
"operator"
]
}
]
+26
View File
@@ -0,0 +1,26 @@
[
{
"mode": "client",
"listen": 5432,
"host": "db",
"target": 8443
},
{
"mode": "client",
"listen": 8333,
"host": "s3",
"target": 8443
},
{
"mode": "client",
"listen": 4318,
"host": "otel-collector",
"target": 8443
},
{
"mode": "client",
"listen": 6380,
"host": "broker",
"target": 8443
}
]
+21
View File
@@ -0,0 +1,21 @@
ui = false
disable_mlock = true
api_addr = "https://openbao:8200"
cluster_addr = "https://127.0.0.1:8201"
audit "file" "operator" {
options {
file_path = "/bao/audit.json"
}
}
storage "raft" {
path = "/bao/data"
node_id = "lab7"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_cert_file = "/identity/cert.pem"
tls_key_file = "/identity/key.pem"
tls_client_ca_file = "/trust/ca.crt"
tls_require_and_verify_client_cert = true
tls_min_version = "tls12"
}
+67
View File
@@ -0,0 +1,67 @@
receivers:
otlp:
protocols:
http:
endpoint: 127.0.0.1:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 192
spike_limit_mib: 48
batch:
timeout: 1s
send_batch_size: 64
send_batch_max_size: 128
exporters:
prometheus:
endpoint: 127.0.0.1:9464
enable_open_metrics: true
metric_expiration: 2m
otlphttp/tempo:
endpoint: http://127.0.0.1:14318
timeout: 2s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 32
retry_on_failure:
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
otlphttp/loki:
endpoint: http://127.0.0.1:13100/otlp
timeout: 2s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 32
retry_on_failure:
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
extensions:
health_check:
endpoint: 127.0.0.1:13133
service:
extensions: [health_check]
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: 127.0.0.1
port: 8888
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp/tempo]
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp/loki]
+12 -5
View File
@@ -1,7 +1,14 @@
# Конфигурация наблюдаемости — реализовать
# Telemetry ЛР7
Добавьте `collector.yaml` с OTLP receivers, processors и exporters выбранной версии Collector. Укажите явные bind endpoints, внутренние сети, memory limits/batch и поведение при backpressure по уровню. Сопоставьте все три pipeline с реально развёрнутыми backend.
Перенесена реализация ЛР6. Collector принимает OTLP HTTP только на loopback;
сеть доступна через otel-collector:8443 с mTLS и SAN allowlist. Native экспорт
Collector → Tempo/Loki идёт в локальные tunnels, которые проверяют server CA/SAN
и предъявляют identity Collector. Prometheus scrape и Grafana queries также
используют разные mTLS identities. Backend ports не публикуются на хосте.
Добавьте конфигурации storage, Grafana provisioning/datasources, provisioning/dashboards и импортируемые dashboard JSON. На 4 — alert rules и runbooks. Пустой dashboard или debug exporter, который только печатает данные в stdout, не заменяют хранилища/доказательства из `contracts/observability.md`.
Не публикуйте OTLP/metrics/административные ports в общую сеть без необходимости. В lab7 реализуйте TLS/mTLS по trust matrix; экспорт Authorization и message bodies запрещён.
Provisioned dashboard: infra/grafana/dashboards/messenger.json. Grafana доступна
на https://localhost:3000, пароль admin создаёт bootstrap; анонимного доступа нет.
Секреты, bodies и Authorization не включены в application spans/logs.
`python checks/telemetry_security.py` проверяет upload trace, correlated logs,
HTTP metric series и отсутствие известных credential canaries. Подробности
в REPORT.md и contracts/trust-matrix.md.
+8
View File
@@ -0,0 +1,8 @@
# Operator-only Unix socket; no socket is shared with app containers.
local all messenger trust
local all all reject
# Plaintext exists only in the db TLS sidecar's shared loopback namespace.
# The TLS boundary enforces the peer identity; PostgreSQL ALSO verifies SCRAM.
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 reject
host all all 0.0.0.0/0 reject
+12
View File
@@ -0,0 +1,12 @@
global:
scrape_interval: 5s
evaluation_interval: 5s
rule_files:
- /etc/prometheus/alerts.yaml
scrape_configs:
- job_name: messenger-otlp
static_configs:
- targets: [127.0.0.1:19464]
- job_name: collector
static_configs:
- targets: [127.0.0.1:18888]
+28
View File
@@ -0,0 +1,28 @@
server:
http_listen_address: 127.0.0.1
grpc_listen_address: 127.0.0.1
http_listen_port: 3200
distributor:
receivers:
otlp:
protocols:
http:
endpoint: 127.0.0.1:4318
ingester:
trace_idle_period: 5s
max_block_duration: 1m
compactor:
compaction:
block_retention: 24h
storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
overrides:
defaults:
ingestion:
rate_limit_bytes: 1000000
burst_size_bytes: 2000000