forked from mtusi2026/mtusi2026lab7
lab7
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
install -o postgres -g postgres -m 600 /pki/service.key /run/pg-tls/server.key
|
||||
install -m 644 /pki/service.crt /run/pg-tls/server.crt
|
||||
exec docker-entrypoint.sh postgres -c ssl=on \
|
||||
-c ssl_cert_file=/run/pg-tls/server.crt -c ssl_key_file=/run/pg-tls/server.key \
|
||||
-c hba_file=/etc/lab-pg-hba.conf -c password_encryption=scram-sha-256 \
|
||||
-c shared_buffers=64MB -c max_connections=60
|
||||
@@ -0,0 +1,43 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
ssl-default-server-options ssl-min-ver TLSv1.2
|
||||
maxconn 256
|
||||
|
||||
defaults
|
||||
mode http
|
||||
timeout connect 500ms
|
||||
timeout client 45s
|
||||
timeout server 50s
|
||||
timeout check 2s
|
||||
retries 0
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 1
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold nx 1s
|
||||
hold obsolete 1s
|
||||
|
||||
frontend public
|
||||
bind :8443 ssl crt /pki/server.pem
|
||||
http-request deny if { path_beg /internal/ }
|
||||
http-request del-header X-Forwarded-For
|
||||
use_backend liveness if { path -m str /health/live }
|
||||
default_backend messenger
|
||||
|
||||
backend messenger
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server ssl verify required verifyhost api ca-file /pki/ca.crt crt /pki/client.pem check inter 1s fall 2 rise 1
|
||||
server-template api 1-2 api:8444 resolvers docker init-addr none resolve-prefer ipv4
|
||||
|
||||
|
||||
backend liveness
|
||||
balance roundrobin
|
||||
option httpchk GET /health/live
|
||||
http-check expect status 200
|
||||
default-server ssl verify required verifyhost api ca-file /pki/ca.crt crt /pki/client.pem check inter 1s fall 2 rise 1
|
||||
server-template live 1-2 api:8444 resolvers docker init-addr none resolve-prefer ipv4
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export MINIO_ROOT_USER=operator
|
||||
export MINIO_ROOT_PASSWORD="$(cat /credentials/root)"
|
||||
exec minio "$@"
|
||||
+20
-4
@@ -1,7 +1,23 @@
|
||||
# OpenBao — реализовать конфигурацию и политики
|
||||
# OpenBao
|
||||
|
||||
Добавьте non-dev конфигурацию listener/storage/TLS, API/worker policies, bootstrap и rotation scripts. Credentials и unseal material создаются локально; здесь нет готового root token или private key.
|
||||
`server.hcl` поднимает OpenBao 2.7.2 с TLS и single-node Raft в volume
|
||||
`bao_raft_active`. Cluster listener привязан к loopback. Клиенты проверяют
|
||||
Lab7 CA и SAN `openbao`; роль cert auth закреплена за публичным leaf и SAN.
|
||||
Только API, dispatcher, worker, reconciler и операторский probe подключены к
|
||||
сети `vault` вместе с OpenBao. TLS-порт оператора опубликован на loopback.
|
||||
|
||||
Решение должно показать реальную сервисную аутентификацию и получение нужного secret по ограниченной policy; просто работающий контейнер OpenBao не засчитывается. На 3 статический KV secret допустим. На 4 покажите expiry/renewal/rotation и allow/deny. Путь KV v2 data/metadata и ACL должен соответствовать фактическому mount; не копируйте широкое `path "*"` для приложения.
|
||||
Первый `scripts/start.sh` вызывает `python3 -m scripts.bao_operator bootstrap`
|
||||
до запуска приложения. Локальный оператор выполняет init, unseal и настройку
|
||||
KV v2/cert auth. Начальный root token отзывается после проверки оператора.
|
||||
Unseal shares хранятся только на хосте в закрытом файле 0600. Два из трёх
|
||||
shares нужны для `python3 -m scripts.bao_operator unseal` после рестарта.
|
||||
|
||||
Документируйте шаги оператора init/unseal и восстановление после restart. Скрипт не должен печатать tokens/shares или хранить их в Git. См. contracts/trust-matrix.md и REPORT.md.
|
||||
Четыре app role читают ровно свой `messenger/data/<role>` и обновляют
|
||||
собственный токен. TTL 30 с, absolute max 5 мин, далее cert re-auth.
|
||||
Короткий локальный lease ограничивает работу с уже загруженным набором
|
||||
credentials, если OpenBao запечатан, cert-login отклонён или KV изменился.
|
||||
Значения не выводятся и не монтируются в app в виде root credential.
|
||||
Оператор управляет cert roles и KV. При DB и S3 ротации он заменяет пароль
|
||||
зависимости и KV. После этого API перечитывает набор при пересоздании.
|
||||
|
||||
Порядок запуска и воспроизводимые проверки — в [REPORT](../../REPORT.md).
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
path "messenger/data/api" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
path "auth/token/renew-self" {
|
||||
capabilities = ["update"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
path "messenger/data/dispatcher" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
path "auth/token/renew-self" {
|
||||
capabilities = ["update"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
path "auth/cert/certs/*" {
|
||||
capabilities = ["create", "read", "update", "delete", "list"]
|
||||
}
|
||||
path "messenger/data/*" {
|
||||
capabilities = ["create", "read", "update"]
|
||||
}
|
||||
path "sys/seal" {
|
||||
capabilities = ["update", "sudo"]
|
||||
}
|
||||
path "auth/token/revoke-accessor" {
|
||||
capabilities = ["update", "sudo"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
path "messenger/data/reconciler" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
path "auth/token/renew-self" {
|
||||
capabilities = ["update"]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
ui = false
|
||||
api_addr = "https://openbao:8200"
|
||||
|
||||
cluster_addr = "https://openbao:8201"
|
||||
|
||||
storage "raft" {
|
||||
node_id = "lab7"
|
||||
path = "/openbao/file"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
cluster_address = "127.0.0.1:8201"
|
||||
tls_cert_file = "/pki/service.crt"
|
||||
tls_key_file = "/pki/service.key"
|
||||
tls_client_ca_file = "/pki/ca.crt"
|
||||
tls_min_version = "tls12"
|
||||
tls_require_and_verify_client_cert = true
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
path "messenger/data/worker" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
path "auth/token/renew-self" {
|
||||
capabilities = ["update"]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
groups:
|
||||
- name: incidents
|
||||
rules:
|
||||
- alert: APIHighErrorRate
|
||||
expr: slo:api_error_ratio:30s > 0.05
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: API 5xx > 5% / 30s
|
||||
runbook: 'REPORT.md: DB incident'
|
||||
- alert: QueueLagGrowing
|
||||
expr: max(queue_oldest_age_seconds) > 15 and max(queue_depth) > 0
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Durable unfinished job age > 15s
|
||||
runbook: 'REPORT.md: worker incident'
|
||||
- alert: APIErrorBudgetBurnFast
|
||||
expr: slo:api_error_ratio:30s > 0.144 and slo:api_error_ratio:2m > 0.144
|
||||
for: 10s
|
||||
labels:
|
||||
severity: critical
|
||||
annotations:
|
||||
summary: 'API 99% SLO: burn >14.4 over 30s AND 2m'
|
||||
runbook: 'REPORT.md: DB incident'
|
||||
- alert: APIErrorBudgetBurnSlow
|
||||
expr: slo:api_error_ratio:1m > 0.06 and slo:api_error_ratio:5m > 0.06
|
||||
for: 20s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: 'API 99% SLO: burn >6 over 1m AND 5m'
|
||||
runbook: 'REPORT.md: DB incident'
|
||||
- alert: ReadyErrorBudgetBurn
|
||||
expr: slo:ready_bad_ratio:30s > 0.144 and slo:ready_bad_ratio:2m > 0.144 and sum(rate(ready_deadline_jobs_total[30s]))
|
||||
> 0
|
||||
for: 10s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: 'Ready <=10s / 99%: burn >14.4'
|
||||
runbook: 'REPORT.md: worker incident'
|
||||
@@ -0,0 +1,100 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 127.0.0.1:13133
|
||||
file_storage:
|
||||
directory: /var/lib/otel
|
||||
compaction:
|
||||
on_start: true
|
||||
directory: /var/lib/otel/compact
|
||||
create_directory: true
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 127.0.0.1:14318
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 160
|
||||
spike_limit_mib: 32
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 128
|
||||
send_batch_max_size: 256
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 127.0.0.1:18889
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
otlphttp/loki:
|
||||
endpoint: https://loki:3100/otlp
|
||||
tls:
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /pki/client/service.crt
|
||||
key_file: /pki/client/service.key
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
queue_size: 32
|
||||
num_consumers: 1
|
||||
storage: file_storage
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 3s
|
||||
max_elapsed_time: 10s
|
||||
otlphttp/tempo:
|
||||
endpoint: https://tempo:4318
|
||||
tls:
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /pki/client/service.crt
|
||||
key_file: /pki/client/service.key
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
queue_size: 32
|
||||
num_consumers: 1
|
||||
storage: file_storage
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 3s
|
||||
max_elapsed_time: 10s
|
||||
service:
|
||||
extensions:
|
||||
- health_check
|
||||
- file_storage
|
||||
telemetry:
|
||||
metrics:
|
||||
level: detailed
|
||||
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:
|
||||
- otlphttp/tempo
|
||||
@@ -0,0 +1,484 @@
|
||||
{
|
||||
"uid": "lab7",
|
||||
"title": "Lab7 \u2014 Messenger observations",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "5s",
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "timeseries",
|
||||
"title": "Business API requests / second",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(app_http_requests_total[1m]))",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "timeseries",
|
||||
"title": "API 5xx / business requests",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "slo:api_error_ratio:1m",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "timeseries",
|
||||
"title": "API latency p50 / p95 / p99, all replicas",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.5,sum by(le)(rate(app_http_duration_seconds_bucket[1m])))",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(app_http_duration_seconds_bucket[1m])))",
|
||||
"refId": "B"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.99,sum by(le)(rate(app_http_duration_seconds_bucket[1m])))",
|
||||
"refId": "C"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "timeseries",
|
||||
"title": "Jobs processed / second by outcome",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum by(outcome)(rate(jobs_processed_total[1m]))",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "timeseries",
|
||||
"title": "Worker processing p95",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(job_duration_seconds_bucket[1m])))",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "timeseries",
|
||||
"title": "Ready time p50 / p95 / p99",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.5,sum by(le)(rate(attachment_ready_seconds_bucket[2m])))",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(attachment_ready_seconds_bucket[2m])))",
|
||||
"refId": "B"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.99,sum by(le)(rate(attachment_ready_seconds_bucket[2m])))",
|
||||
"refId": "C"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "timeseries",
|
||||
"title": "Durable unfinished jobs",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(queue_depth)",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "timeseries",
|
||||
"title": "Oldest unfinished job / seconds",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(queue_oldest_age_seconds)",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"type": "timeseries",
|
||||
"title": "DB pool used / waiting",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(db_pool_used)",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "sum(db_pool_waiting)",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"type": "timeseries",
|
||||
"title": "Worker busy / capacity",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(worker_busy)",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "sum(worker_capacity)",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"type": "timeseries",
|
||||
"title": "Process CPU / cores",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(process_cpu_seconds[1m])",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"type": "timeseries",
|
||||
"title": "Process RSS high water / bytes",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "process_memory_bytes",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"type": "timeseries",
|
||||
"title": "API budget burn / 30s / 2m / 5m",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "slo:api_error_ratio:30s / 0.01",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "slo:api_error_ratio:2m / 0.01",
|
||||
"refId": "B"
|
||||
},
|
||||
{
|
||||
"expr": "slo:api_error_ratio:5m / 0.01",
|
||||
"refId": "C"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"type": "timeseries",
|
||||
"title": "Active alerts",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "ALERTS{alertstate=\"firing\"}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"type": "timeseries",
|
||||
"title": "Queue probe valid (0 = DB unavailable)",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "queue_probe_ok_ratio",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"type": "timeseries",
|
||||
"title": "Collector failed exports / refused spans",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(otelcol_exporter_send_failed_spans_total[1m])",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "rate(otelcol_receiver_refused_spans_total[1m])",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"lab7"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: Lab6
|
||||
type: file
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,34 @@
|
||||
auth_enabled: false
|
||||
server:
|
||||
http_listen_address: 127.0.0.1
|
||||
http_listen_port: 13100
|
||||
grpc_listen_address: 127.0.0.1
|
||||
common:
|
||||
path_prefix: /loki
|
||||
instance_addr: 127.0.0.1
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
schema_config:
|
||||
configs:
|
||||
- from: '2024-01-01'
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
limits_config:
|
||||
allow_structured_metadata: true
|
||||
retention_period: 48h
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
analytics:
|
||||
reporting_enabled: false
|
||||
@@ -0,0 +1,25 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
rule_files:
|
||||
- /etc/prometheus/recording.yaml
|
||||
- /etc/prometheus/alerts.yaml
|
||||
scrape_configs:
|
||||
- job_name: application
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /pki/service.crt
|
||||
key_file: /pki/service.key
|
||||
static_configs:
|
||||
- targets:
|
||||
- collector:8889
|
||||
- job_name: collector
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /pki/ca.crt
|
||||
cert_file: /pki/service.crt
|
||||
key_file: /pki/service.key
|
||||
static_configs:
|
||||
- targets:
|
||||
- collector:8888
|
||||
@@ -0,0 +1,28 @@
|
||||
groups:
|
||||
- name: slo
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: slo:api_error_ratio:30s
|
||||
expr: (sum(rate(app_http_requests_total{status_class="5xx",route!~"/health.*"}[30s]))
|
||||
or vector(0)) / clamp_min(sum(rate(app_http_requests_total{route!~"/health.*"}[30s])),
|
||||
0.001)
|
||||
- record: slo:ready_bad_ratio:30s
|
||||
expr: sum(rate(ready_deadline_missed_total[30s])) / clamp_min(sum(rate(ready_deadline_jobs_total[30s])),0.001)
|
||||
- record: slo:api_error_ratio:1m
|
||||
expr: (sum(rate(app_http_requests_total{status_class="5xx",route!~"/health.*"}[1m]))
|
||||
or vector(0)) / clamp_min(sum(rate(app_http_requests_total{route!~"/health.*"}[1m])),
|
||||
0.001)
|
||||
- record: slo:ready_bad_ratio:1m
|
||||
expr: sum(rate(ready_deadline_missed_total[1m])) / clamp_min(sum(rate(ready_deadline_jobs_total[1m])),0.001)
|
||||
- record: slo:api_error_ratio:2m
|
||||
expr: (sum(rate(app_http_requests_total{status_class="5xx",route!~"/health.*"}[2m]))
|
||||
or vector(0)) / clamp_min(sum(rate(app_http_requests_total{route!~"/health.*"}[2m])),
|
||||
0.001)
|
||||
- record: slo:ready_bad_ratio:2m
|
||||
expr: sum(rate(ready_deadline_missed_total[2m])) / clamp_min(sum(rate(ready_deadline_jobs_total[2m])),0.001)
|
||||
- record: slo:api_error_ratio:5m
|
||||
expr: (sum(rate(app_http_requests_total{status_class="5xx",route!~"/health.*"}[5m]))
|
||||
or vector(0)) / clamp_min(sum(rate(app_http_requests_total{route!~"/health.*"}[5m])),
|
||||
0.001)
|
||||
- record: slo:ready_bad_ratio:5m
|
||||
expr: sum(rate(ready_deadline_missed_total[5m])) / clamp_min(sum(rate(ready_deadline_jobs_total[5m])),0.001)
|
||||
@@ -0,0 +1,25 @@
|
||||
server:
|
||||
http_listen_address: 127.0.0.1
|
||||
http_listen_port: 13200
|
||||
grpc_listen_address: 127.0.0.1
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 127.0.0.1:14318
|
||||
ingester:
|
||||
trace_idle_period: 5s
|
||||
max_block_duration: 1m
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 48h
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
usage_report:
|
||||
reporting_enabled: false
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
for role in api worker dispatcher reconciler; do
|
||||
LAB_ROLE_PASSWORD="$(cat "/credentials/$role")" \
|
||||
psql -q -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" \
|
||||
-v role="lab_$role" <<'SQL'
|
||||
\getenv pw LAB_ROLE_PASSWORD
|
||||
CREATE ROLE :"role" LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION PASSWORD :'pw';
|
||||
SQL
|
||||
done
|
||||
@@ -0,0 +1,3 @@
|
||||
local all all peer
|
||||
hostssl messenger all 0.0.0.0/0 scram-sha-256
|
||||
hostssl messenger all ::/0 scram-sha-256
|
||||
@@ -0,0 +1,10 @@
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
protected-mode yes
|
||||
dir /data
|
||||
appendonly yes
|
||||
appendfsync always
|
||||
save ""
|
||||
maxmemory 160mb
|
||||
maxmemory-policy noeviction
|
||||
aclfile /credentials/users.acl
|
||||
@@ -0,0 +1,27 @@
|
||||
# syntax=docker/dockerfile:1.7.0
|
||||
FROM python:3.12.10-slim-bookworm
|
||||
ARG COMPONENT
|
||||
ARG RELEASE
|
||||
ARG SHA256
|
||||
RUN python - <<'PY'
|
||||
import hashlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import urllib.request
|
||||
|
||||
component = os.environ['COMPONENT']
|
||||
release = os.environ['RELEASE']
|
||||
assert component in {'minio', 'mc'}
|
||||
name = f'{component}.linux-amd64.{release}'
|
||||
url = f'https://github.com/minio/{component}/releases/download/{release}/{name}'
|
||||
target = Path('/usr/local/bin') / component
|
||||
with urllib.request.urlopen(url, timeout=180) as response, target.open('wb') as file:
|
||||
shutil.copyfileobj(response, file)
|
||||
with target.open('rb') as file:
|
||||
digest = hashlib.file_digest(file, 'sha256').hexdigest()
|
||||
assert digest == os.environ['SHA256'], 'Unexpected binary checksum'
|
||||
target.chmod(0o755)
|
||||
PY
|
||||
COPY infra/minio-entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:PutObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/staging/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/originals/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/variants/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments"
|
||||
],
|
||||
"Condition": {
|
||||
"StringLike": {
|
||||
"s3:prefix": [
|
||||
"originals/"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/staging/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments"
|
||||
],
|
||||
"Condition": {
|
||||
"StringLike": {
|
||||
"s3:prefix": [
|
||||
"staging/"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/staging/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/originals/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/variants/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
maxconn 128
|
||||
|
||||
defaults
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
retries 0
|
||||
|
||||
listen streams
|
||||
mode tcp
|
||||
bind :6380 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
tcp-request content reject unless { ssl_c_s_dn(CN) -m str dispatcher worker }
|
||||
server redis 127.0.0.1:6379
|
||||
@@ -0,0 +1,27 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
maxconn 128
|
||||
|
||||
defaults
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
retries 0
|
||||
|
||||
listen ingest
|
||||
mode http
|
||||
bind :4318 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str api worker dispatcher reconciler } { method POST } { path -m str /v1/logs /v1/traces /v1/metrics }
|
||||
server local 127.0.0.1:14318
|
||||
|
||||
listen app_metrics
|
||||
mode http
|
||||
bind :8889 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str scraper } { method GET } { path -m str /metrics }
|
||||
server local 127.0.0.1:18889
|
||||
|
||||
listen collector_metrics
|
||||
mode http
|
||||
bind :8888 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str scraper } { method GET } { path -m str /metrics }
|
||||
server local 127.0.0.1:18888
|
||||
@@ -0,0 +1,17 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
maxconn 128
|
||||
|
||||
defaults
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
retries 0
|
||||
|
||||
listen logs
|
||||
mode http
|
||||
bind :3100 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request allow if { ssl_c_s_dn(CN) -m str collector-export } { ssl_c_der,sha2(256),hex,lower -m str -f /pki/collector-fingerprint } { method POST } { path -m str /otlp/v1/logs }
|
||||
http-request allow if { ssl_c_s_dn(CN) -m str grafana operator } { method GET } { path_beg /loki/api/v1/ }
|
||||
http-request deny
|
||||
server local 127.0.0.1:13100
|
||||
@@ -0,0 +1,15 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
maxconn 128
|
||||
|
||||
defaults
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
retries 0
|
||||
|
||||
listen query
|
||||
mode http
|
||||
bind :9090 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str grafana operator } { method GET POST } { path -m reg ^/api/v1/(query|query_range|labels|series|label/[^/]+/values|status/buildinfo|alerts|rules)$ }
|
||||
server local 127.0.0.1:19090
|
||||
@@ -0,0 +1,21 @@
|
||||
global
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
||||
maxconn 128
|
||||
|
||||
defaults
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
retries 0
|
||||
|
||||
listen query
|
||||
mode http
|
||||
bind :3200 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str grafana operator } { method GET } { path_beg /api/ }
|
||||
server local 127.0.0.1:13200
|
||||
|
||||
listen ingest
|
||||
mode http
|
||||
bind :4318 ssl crt /pki/service.pem ca-file /pki/ca.crt verify required
|
||||
http-request deny unless { ssl_c_s_dn(CN) -m str collector-export } { ssl_c_der,sha2(256),hex,lower -m str -f /pki/collector-fingerprint } { method POST } { path -m str /v1/traces }
|
||||
server local 127.0.0.1:14318
|
||||
Reference in New Issue
Block a user