ЛР 7 — БВТ2303 — Брезгунова — на 5
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
FROM golang:1.24.2-bookworm AS server-build
|
||||
RUN git clone --depth 1 --branch RELEASE.2025-04-22T22-12-26Z https://github.com/minio/minio.git /source
|
||||
WORKDIR /source
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="$(go run buildscripts/gen-ldflags.go)" -o /out/minio .
|
||||
|
||||
FROM golang:1.24.2-bookworm AS client-build
|
||||
RUN git clone --depth 1 --branch RELEASE.2025-04-16T18-13-26Z https://github.com/minio/mc.git /source
|
||||
WORKDIR /source
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="$(go run buildscripts/gen-ldflags.go)" -o /out/mc .
|
||||
|
||||
FROM python:3.12.11-slim-bookworm AS server
|
||||
COPY --from=server-build /out/minio /usr/local/bin/minio
|
||||
LABEL org.opencontainers.image.source="https://github.com/minio/minio" org.opencontainers.image.version="RELEASE.2025-04-22T22-12-26Z"
|
||||
ENTRYPOINT ["minio"]
|
||||
|
||||
FROM python:3.12.11-slim-bookworm AS client
|
||||
COPY --from=client-build /out/mc /usr/local/bin/mc
|
||||
LABEL org.opencontainers.image.source="https://github.com/minio/mc" org.opencontainers.image.version="RELEASE.2025-04-16T18-13-26Z"
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -0,0 +1 @@
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::messenger-attachments"]},{"Effect":"Allow","Action":["s3:PutObject","s3:GetObject"],"Resource":["arn:aws:s3:::messenger-attachments/staging/*"]},{"Effect":"Allow","Action":["s3:GetObject"],"Resource":["arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export SSL_CERT_FILE=/run/pki/ca.crt
|
||||
mc alias set local https://s3:9000 "$(cat /run/secrets/minio_root_user)" "$(cat /run/secrets/minio_root_password)" >/dev/null
|
||||
mc mb --ignore-existing local/messenger-attachments >/dev/null
|
||||
mc anonymous set none local/messenger-attachments >/dev/null
|
||||
for role in api worker operator; do
|
||||
mc admin policy create local messenger-$role /config/$role-policy.json >/dev/null
|
||||
mc admin user add local "$(cat /run/secrets/${role}_s3_key)" "$(cat /run/secrets/${role}_s3_secret)" >/dev/null
|
||||
mc admin policy attach local messenger-$role --user "$(cat /run/secrets/${role}_s3_key)" >/dev/null
|
||||
done
|
||||
echo 'Private bucket, scoped users and policies prepared over verified TLS.'
|
||||
@@ -0,0 +1,10 @@
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
protected-mode yes
|
||||
aclfile /run/broker.acl
|
||||
dir /data
|
||||
appendonly yes
|
||||
appendfsync always
|
||||
save ""
|
||||
maxmemory 128mb
|
||||
maxmemory-policy noeviction
|
||||
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"port": 8443,
|
||||
"target": 8080,
|
||||
"clients": [
|
||||
"lb"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"port": 8443,
|
||||
"target": 8080,
|
||||
"clients": [
|
||||
"lb"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"port": 6380,
|
||||
"target": 6379,
|
||||
"clients": [
|
||||
"api1",
|
||||
"api2",
|
||||
"worker",
|
||||
"publisher",
|
||||
"operator"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"port": 3443,
|
||||
"target": 3000,
|
||||
"clients": []
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,49 @@
|
||||
[
|
||||
{
|
||||
"port": 3443,
|
||||
"target": 3100,
|
||||
"clients": [
|
||||
"otel-collector",
|
||||
"grafana",
|
||||
"operator"
|
||||
],
|
||||
"http_permissions": {
|
||||
"grafana": [
|
||||
{
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST"
|
||||
],
|
||||
"paths": [
|
||||
"/ready",
|
||||
"/loki/api/v1/query",
|
||||
"/loki/api/v1/query_range",
|
||||
"/loki/api/v1/labels",
|
||||
"/loki/api/v1/series",
|
||||
"/loki/api/v1/index/stats",
|
||||
"/loki/api/v1/index/volume",
|
||||
"/loki/api/v1/index/volume_range"
|
||||
]
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"prefix_paths": [
|
||||
"/loki/api/v1/label/"
|
||||
]
|
||||
}
|
||||
],
|
||||
"otel-collector": [
|
||||
{
|
||||
"methods": [
|
||||
"POST"
|
||||
],
|
||||
"paths": [
|
||||
"/otlp/v1/logs"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
[
|
||||
{
|
||||
"port": 4319,
|
||||
"target": 4318,
|
||||
"clients": [
|
||||
"api1",
|
||||
"api2",
|
||||
"worker",
|
||||
"publisher",
|
||||
"janitor",
|
||||
"operator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"port": 8890,
|
||||
"target": 8889,
|
||||
"clients": [
|
||||
"prometheus",
|
||||
"operator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"port": 8887,
|
||||
"target": 8888,
|
||||
"clients": [
|
||||
"prometheus",
|
||||
"operator"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,38 @@
|
||||
[
|
||||
{
|
||||
"port": 9443,
|
||||
"target": 9090,
|
||||
"clients": [
|
||||
"grafana",
|
||||
"operator"
|
||||
],
|
||||
"http_permissions": {
|
||||
"grafana": [
|
||||
{
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST"
|
||||
],
|
||||
"paths": [
|
||||
"/-/ready",
|
||||
"/api/v1/query",
|
||||
"/api/v1/query_range",
|
||||
"/api/v1/labels",
|
||||
"/api/v1/series",
|
||||
"/api/v1/metadata",
|
||||
"/api/v1/status/buildinfo",
|
||||
"/api/v1/status/runtimeinfo"
|
||||
]
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"prefix_paths": [
|
||||
"/api/v1/label/"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
[
|
||||
{
|
||||
"port": 3443,
|
||||
"target": 3200,
|
||||
"clients": [
|
||||
"grafana",
|
||||
"operator"
|
||||
],
|
||||
"http_permissions": {
|
||||
"grafana": [
|
||||
{
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST"
|
||||
],
|
||||
"paths": [
|
||||
"/ready",
|
||||
"/api/search",
|
||||
"/api/v2/search",
|
||||
"/api/search/tags",
|
||||
"/api/v2/search/tags",
|
||||
"/api/metrics/query",
|
||||
"/api/metrics/query_range"
|
||||
]
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"prefix_paths": [
|
||||
"/api/traces/",
|
||||
"/api/v2/traces/",
|
||||
"/api/search/tag/",
|
||||
"/api/v2/search/tag/"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"port": 4438,
|
||||
"target": 4318,
|
||||
"clients": [
|
||||
"otel-collector",
|
||||
"operator"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,740 @@
|
||||
{
|
||||
"uid": "messenger-lab7",
|
||||
"title": "Messenger Lab7: secure metrics, logs, traces",
|
||||
"schemaVersion": 40,
|
||||
"version": 1,
|
||||
"editable": false,
|
||||
"refresh": "5s",
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"tags": [
|
||||
"lab6"
|
||||
],
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API RPS",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(http_server_requests_total{service_name=\"messenger-api\"}[1m]))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "sum(rate(http_server_requests_total{service_name=\"messenger-api\"}[1m]))"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API 5xx ratio",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(http_server_requests_total{service_name=\"messenger-api\",status_class=\"5xx\"}[1m])) / clamp_min(sum(rate(http_server_requests_total{service_name=\"messenger-api\"}[1m])),0.001)",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "5xx / all business API responses, excludes health, includes client 4xx in denominator."
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "API p50",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5,sum by(le)(rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\"}[1m])))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "Histogram buckets aggregated across API replicas before quantile; seconds."
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "API p95",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\"}[1m])))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "Histogram buckets aggregated across API replicas before quantile; seconds."
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "API p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.99,sum by(le)(rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\"}[1m])))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "Histogram buckets aggregated across API replicas before quantile; seconds."
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Worker outcomes",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by(outcome)(rate(worker_jobs_total{service_name=\"messenger-worker\"}[1m]))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "sum by(outcome)(rate(worker_jobs_total{service_name=\"messenger-worker\"}[1m]))"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Worker p95 processing",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(worker_job_duration_seconds_bucket{service_name=\"messenger-worker\"}[1m])))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "histogram_quantile(0.95,sum by(le)(rate(worker_job_duration_seconds_bucket{service_name=\"messenger-worker\"}[1m])))"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Ready p95 end to end",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95,sum by(le)(rate(attachment_ready_duration_seconds_bucket[1m])))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "histogram_quantile(0.95,sum by(le)(rate(attachment_ready_duration_seconds_bucket[1m])))"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Durable queue depth",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(queue_depth{service_name=\"messenger-publisher\"})",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "max(queue_depth{service_name=\"messenger-publisher\"})"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Oldest unfinished job",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(queue_oldest_age_seconds{service_name=\"messenger-publisher\"})",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "max(queue_oldest_age_seconds{service_name=\"messenger-publisher\"})"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "DB pool used / process",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "db_pool_used",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "db_pool_used"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "DB pool waiting / process",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "db_pool_waiting",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "db_pool_waiting"
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "Worker busy / configured capacity",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(worker_busy)/clamp_min(max(worker_capacity),1)",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "max(worker_busy)/clamp_min(max(worker_capacity),1)"
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"title": "Process resident RAM",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "process_memory_bytes",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "process_memory_bytes"
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"title": "Process CPU cores",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "rate(process_cpu_seconds_total[1m])",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "rate(process_cpu_seconds_total[1m])"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"title": "Local alerts",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 56,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "ALERTS{alertstate=\"firing\"}",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "ALERTS{alertstate=\"firing\"}"
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"title": "API structured logs",
|
||||
"type": "logs",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 64,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=\"messenger-api\"} | json",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "{service_name=\"messenger-api\"} | json"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"title": "Worker structured logs",
|
||||
"type": "logs",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 64,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=\"messenger-worker\"} | json",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "{service_name=\"messenger-worker\"} | json"
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"title": "Exporter failed spans",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 72,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[1m]))",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "sum(rate(otelcol_exporter_send_failed_spans_total[1m]))"
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"title": "Collector queue usage",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 72,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "otelcol_exporter_queue_size / clamp_min(otelcol_exporter_queue_capacity,1)",
|
||||
"legendFormat": "{{service_instance_id}} {{outcome}}",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "table",
|
||||
"placement": "bottom"
|
||||
}
|
||||
},
|
||||
"description": "otelcol_exporter_queue_size / clamp_min(otelcol_exporter_queue_capacity,1)"
|
||||
}
|
||||
],
|
||||
"annotations": {
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: Messenger
|
||||
orgId: 1
|
||||
folder: Lab6
|
||||
type: file
|
||||
disableDeletion: true
|
||||
options: {path: /var/lib/grafana/dashboards}
|
||||
@@ -0,0 +1,34 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
jsonData: {timeInterval: 3s}
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- name: TraceID
|
||||
matcherRegex: '"trace_id":"([a-f0-9]{32})"'
|
||||
datasourceUid: tempo
|
||||
url: '$${__value.raw}'
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
spanStartTimeShift: '-1m'
|
||||
spanEndTimeShift: '1m'
|
||||
filterByTraceID: true
|
||||
filterBySpanID: false
|
||||
tags: [{key: service.name, value: service_name}]
|
||||
nodeGraph: {enabled: true}
|
||||
@@ -0,0 +1,26 @@
|
||||
global
|
||||
maxconn 128
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2
|
||||
ssl-default-server-options ssl-min-ver TLSv1.2
|
||||
defaults
|
||||
mode http
|
||||
timeout connect 5s
|
||||
timeout check 5s
|
||||
timeout client 35s
|
||||
timeout server 35s
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
hold valid 1s
|
||||
hold obsolete 1s
|
||||
frontend public
|
||||
bind *:8443 ssl crt /run/tls/bundle.pem
|
||||
http-request deny if { path_beg /internal-test/ }
|
||||
default_backend api
|
||||
backend api
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
retries 2
|
||||
option redispatch
|
||||
server api1 api1:8443 ssl verify required ca-file /run/pki/ca.crt crt /run/tls/bundle.pem verifyhost api1 sni str(api1) check check-sni api1 inter 1s fall 1 rise 1 resolvers docker init-addr libc,none
|
||||
server api2 api2:8443 ssl verify required ca-file /run/pki/ca.crt crt /run/tls/bundle.pem verifyhost api2 sni str(api2) check check-sni api2 inter 1s fall 1 rise 1 resolvers docker init-addr libc,none
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export MINIO_ROOT_USER="$(cat /run/secrets/minio_root_user)"
|
||||
export MINIO_ROOT_PASSWORD="$(cat /run/secrets/minio_root_password)"
|
||||
mkdir -p /tmp/minio-certs
|
||||
cp /run/tls/cert.crt /tmp/minio-certs/public.crt
|
||||
cp /run/tls/key.key /tmp/minio-certs/private.key
|
||||
exec minio server /data --address :9000 --console-address 127.0.0.1:9001 --certs-dir /tmp/minio-certs
|
||||
@@ -0,0 +1,10 @@
|
||||
ui = true
|
||||
api_addr = "https://openbao:8200"
|
||||
storage "file" { path = "/bao/data" }
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
tls_cert_file = "/run/tls/cert.crt"
|
||||
tls_key_file = "/run/tls/key.key"
|
||||
tls_client_ca_file = "/run/pki/ca.crt"
|
||||
tls_min_version = "tls12"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
path "secret/data/api1" { capabilities = ["read"] }
|
||||
@@ -0,0 +1 @@
|
||||
path "secret/data/api2" { capabilities = ["read"] }
|
||||
@@ -0,0 +1 @@
|
||||
path "secret/data/janitor" { capabilities = ["read"] }
|
||||
@@ -0,0 +1 @@
|
||||
path "secret/data/publisher" { capabilities = ["read"] }
|
||||
@@ -0,0 +1 @@
|
||||
path "secret/data/worker" { capabilities = ["read"] }
|
||||
@@ -0,0 +1 @@
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::messenger-attachments"]},{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject","s3:DeleteObject"],"Resource":["arn:aws:s3:::messenger-attachments/staging/*","arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
@@ -0,0 +1,37 @@
|
||||
groups:
|
||||
- name: lab6-slo
|
||||
interval: 3s
|
||||
rules:
|
||||
- record: messenger:api_error_ratio:15s
|
||||
expr: sum(rate(http_server_requests_total{service_name="messenger-api",status_class="5xx"}[15s])) / clamp_min(sum(rate(http_server_requests_total{service_name="messenger-api"}[15s])), 0.001)
|
||||
- record: messenger:api_error_ratio:60s
|
||||
expr: sum(rate(http_server_requests_total{service_name="messenger-api",status_class="5xx"}[60s])) / clamp_min(sum(rate(http_server_requests_total{service_name="messenger-api"}[60s])), 0.001)
|
||||
- alert: APIHighErrorRate
|
||||
expr: messenger:api_error_ratio:15s > 0.05
|
||||
for: 6s
|
||||
labels: {severity: warning}
|
||||
annotations:
|
||||
summary: Business API 5xx exceeds 5 percent over 15 seconds
|
||||
runbook_url: https://localhost:3007/d/messenger-lab7
|
||||
description: See RUNBOOK.md. Use storage.failure logs and db spans to distinguish DB failure from handler latency.
|
||||
- alert: APIErrorBudgetBurn
|
||||
expr: (messenger:api_error_ratio:15s / 0.01 > 6) and (messenger:api_error_ratio:60s / 0.01 > 6)
|
||||
for: 10s
|
||||
labels: {severity: critical}
|
||||
annotations:
|
||||
summary: API 99 percent SLO consumes budget at more than 6x in both windows
|
||||
description: Educational compressed windows 15s and 60s; see RUNBOOK.md for production limitations.
|
||||
- alert: QueueLagGrowing
|
||||
expr: max(queue_oldest_age_seconds{service_name="messenger-publisher"}) > 10 and max(deriv(queue_oldest_age_seconds{service_name="messenger-publisher"}[15s])) > 0.1
|
||||
for: 6s
|
||||
labels: {severity: warning}
|
||||
annotations:
|
||||
summary: Durable backlog age exceeds 10 seconds and grows
|
||||
description: Check worker busy/capacity, job completions, consumer logs and trace. Restore worker and verify backlog drains.
|
||||
- alert: ReadyErrorBudgetBurn
|
||||
expr: ((sum(rate(attachment_ready_duration_seconds_count[15s])) - sum(rate(attachment_ready_duration_seconds_bucket{le="10"}[15s]))) / clamp_min(sum(rate(attachment_ready_duration_seconds_count[15s])),0.001) / 0.05 > 3) and ((sum(rate(attachment_ready_duration_seconds_count[60s])) - sum(rate(attachment_ready_duration_seconds_bucket{le="10"}[60s]))) / clamp_min(sum(rate(attachment_ready_duration_seconds_count[60s])),0.001) / 0.05 > 3)
|
||||
for: 6s
|
||||
labels: {severity: warning}
|
||||
annotations:
|
||||
summary: Ready within 10s SLO budget burns in both windows
|
||||
description: Completed-job SLI has survivorship delay; QueueLagGrowing covers uncompleted jobs. See RUNBOOK.md.
|
||||
@@ -0,0 +1,53 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc: {endpoint: "127.0.0.1:4317"}
|
||||
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: 128
|
||||
send_batch_max_size: 256
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: "127.0.0.1:8889"
|
||||
resource_to_telemetry_conversion: {enabled: true}
|
||||
otlphttp/tempo:
|
||||
endpoint: https://tempo:4438
|
||||
tls: {ca_file: /run/pki/ca.crt, cert_file: /run/tls/cert.crt, key_file: /run/tls/key.key}
|
||||
timeout: 2s
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 64}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 5s, max_elapsed_time: 15s}
|
||||
otlphttp/loki:
|
||||
endpoint: https://loki:3443/otlp
|
||||
tls: {ca_file: /run/pki/ca.crt, cert_file: /run/tls/cert.crt, key_file: /run/tls/key.key}
|
||||
timeout: 2s
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 64}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 5s, max_elapsed_time: 15s}
|
||||
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:
|
||||
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,24 @@
|
||||
auth_enabled: false
|
||||
server: {http_listen_address: 127.0.0.1, http_listen_port: 3100, grpc_listen_address: 127.0.0.1}
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: /loki
|
||||
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: 168h
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
analytics: {reporting_enabled: false}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"global": {
|
||||
"scrape_interval": "3s",
|
||||
"evaluation_interval": "3s"
|
||||
},
|
||||
"rule_files": [
|
||||
"/etc/prometheus/alerts.yaml"
|
||||
],
|
||||
"scrape_configs": [
|
||||
{
|
||||
"job_name": "messenger",
|
||||
"scheme": "https",
|
||||
"tls_config": {
|
||||
"ca_file": "/run/pki/ca.crt",
|
||||
"cert_file": "/run/tls/cert.crt",
|
||||
"key_file": "/run/tls/key.key"
|
||||
},
|
||||
"static_configs": [
|
||||
{
|
||||
"targets": [
|
||||
"otel-collector:8890"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"job_name": "collector",
|
||||
"scheme": "https",
|
||||
"tls_config": {
|
||||
"ca_file": "/run/pki/ca.crt",
|
||||
"cert_file": "/run/tls/cert.crt",
|
||||
"key_file": "/run/tls/key.key"
|
||||
},
|
||||
"static_configs": [
|
||||
{
|
||||
"targets": [
|
||||
"otel-collector:8887"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
server: {http_listen_address: 127.0.0.1, http_listen_port: 3200, grpc_listen_address: 127.0.0.1}
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc: {endpoint: "127.0.0.1:4317"}
|
||||
http: {endpoint: "127.0.0.1:4318"}
|
||||
ingester: {max_block_duration: 5m, lifecycler: {address: 127.0.0.1}}
|
||||
compactor:
|
||||
compaction: {block_retention: 168h}
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal: {path: /var/tempo/wal}
|
||||
local: {path: /var/tempo/blocks}
|
||||
usage_report: {reporting_enabled: false}
|
||||
@@ -0,0 +1,5 @@
|
||||
local all all trust
|
||||
hostnossl all all 0.0.0.0/0 reject
|
||||
hostssl messenger all 0.0.0.0/0 scram-sha-256
|
||||
hostnossl all all ::/0 reject
|
||||
hostssl messenger all ::/0 scram-sha-256
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cp /run/tls/key.key /tmp/server.key
|
||||
cp /run/tls/cert.crt /tmp/server.crt
|
||||
chmod 600 /tmp/server.key
|
||||
chown postgres:postgres /tmp/server.key /tmp/server.crt
|
||||
exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/tmp/server.crt -c ssl_key_file=/tmp/server.key -c hba_file=/etc/postgresql/pg_hba.conf
|
||||
@@ -0,0 +1 @@
|
||||
{"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/staging/*"]},{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject"],"Resource":["arn:aws:s3:::messenger-attachments/results/*"]}]}
|
||||
Reference in New Issue
Block a user