forked from mtusi2026/mtusi2026lab7
Добавил TLS и защиту мессенджера для лабораторной 7
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Конфигурация наблюдаемости — реализовать
|
||||
|
||||
Добавьте `collector.yaml` с OTLP receivers, processors и exporters выбранной версии Collector. Укажите явные bind endpoints, внутренние сети, memory limits/batch и поведение при backpressure по уровню. Сопоставьте все три pipeline с реально развёрнутыми backend.
|
||||
`collector.yaml` принимает OTLP/HTTP и gRPC по TLS с клиентскими сертификатами. API и worker имеют разные URI identities; metrics scrape Collector выполняется по HTTPS. `memory_limiter` ограничивает память 256 MiB, batch объединяет записи. Backends Prometheus/Loki/Tempo не публикуют порты: Collector и Grafana ходят к ним через TLS gateway HAProxy. После TLS gateway используется закрытый plaintext hop по внутренней telemetry network.
|
||||
|
||||
Добавьте конфигурации storage, Grafana provisioning/datasources, provisioning/dashboards и импортируемые dashboard JSON. На 4 — alert rules и runbooks. Пустой dashboard или debug exporter, который только печатает данные в stdout, не заменяют хранилища/доказательства из `contracts/observability.md`.
|
||||
Prometheus, Loki, Tempo и Grafana имеют named volumes и provisioning. Grafana admin использует HTTPS и опубликован только на `127.0.0.1:3000`. Для ротации leaf-сертификатов вручную перевыпустите сертификат с тем же SAN и перезапустите потребителей.
|
||||
|
||||
Не публикуйте OTLP/metrics/административные ports в общую сеть без необходимости. В lab7 реализуйте TLS/mTLS по trust matrix; экспорт Authorization и message bodies запрещён.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
tls:
|
||||
cert_file: /run/pki/otel-collector.crt
|
||||
key_file: /run/pki/otel-collector.key
|
||||
client_ca_file: /run/pki/ca.crt
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
tls:
|
||||
cert_file: /run/pki/otel-collector.crt
|
||||
key_file: /run/pki/otel-collector.key
|
||||
client_ca_file: /run/pki/ca.crt
|
||||
processors:
|
||||
memory_limiter: {check_interval: 1s, limit_mib: 256, spike_limit_mib: 64}
|
||||
batch: {timeout: 2s, send_batch_size: 512}
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
tls:
|
||||
cert_file: /run/pki/otel-collector.crt
|
||||
key_file: /run/pki/otel-collector.key
|
||||
namespace: messenger
|
||||
send_timestamps: true
|
||||
metric_expiration: 5m
|
||||
otlphttp/tempo:
|
||||
endpoint: https://lb:9743
|
||||
tls: {ca_file: /run/pki/ca.crt}
|
||||
otlphttp/loki:
|
||||
endpoint: https://lb:9643/otlp
|
||||
tls: {ca_file: /run/pki/ca.crt}
|
||||
extensions:
|
||||
health_check: {endpoint: 0.0.0.0:13133}
|
||||
service:
|
||||
extensions: [health_check]
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/tempo]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"uid": "messenger-overview",
|
||||
"title": "Messenger: API и обработчик вложений",
|
||||
"tags": ["lab6", "otel"],
|
||||
"timezone": "browser",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "10s",
|
||||
"time": {"from": "now-30m", "to": "now"},
|
||||
"panels": [
|
||||
{"id": 1, "type": "timeseries", "title": "HTTP запросы/сек", "datasource": {"type": "prometheus", "uid": "prometheus"}, "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}, "targets": [{"expr": "sum(rate(messenger_messenger_http_requests_total[5m])) by (http_route)", "legendFormat": "{{http_route}}"}]},
|
||||
{"id": 2, "type": "timeseries", "title": "HTTP 5xx/сек (без health)", "datasource": {"type": "prometheus", "uid": "prometheus"}, "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}, "targets": [{"expr": "sum(rate(messenger_messenger_http_requests_total{http_response_status_class=\"5xx\",http_route!~\"/health.*\"}[5m])) by (http_response_status_class)"}]},
|
||||
{"id": 3, "type": "timeseries", "title": "HTTP p95", "datasource": {"type": "prometheus", "uid": "prometheus"}, "gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}, "targets": [{"expr": "histogram_quantile(0.95, sum(rate(messenger_messenger_http_request_duration_seconds_bucket[5m])) by (le,http_route))"}]},
|
||||
{"id": 4, "type": "timeseries", "title": "Задания worker", "datasource": {"type": "prometheus", "uid": "prometheus"}, "gridPos": {"h": 8, "w": 12, "x": 12, "y": 8}, "targets": [{"expr": "sum(rate(messenger_messenger_jobs_total[5m])) by (job_type,outcome)"}]},
|
||||
{"id": 5, "type": "timeseries", "title": "Длительность заданий worker p95, секунды", "datasource": {"type": "prometheus", "uid": "prometheus"}, "gridPos": {"h": 8, "w": 12, "x": 0, "y": 16}, "targets": [{"expr": "histogram_quantile(0.95, sum(rate(messenger_messenger_job_duration_seconds_bucket[5m])) by (le,job_type,outcome))", "legendFormat": "{{job_type}} / {{outcome}}"}]},
|
||||
{"id": 6, "type": "logs", "title": "Логи приложения", "datasource": {"type": "loki", "uid": "loki"}, "gridPos": {"h": 10, "w": 24, "x": 0, "y": 24}, "targets": [{"expr": "{service_name=~\"messenger-api|messenger-worker\"}"}]}
|
||||
],
|
||||
"annotations": {"list": []},
|
||||
"templating": {"list": []}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: messenger
|
||||
orgId: 1
|
||||
folder: Messenger
|
||||
type: file
|
||||
disableDeletion: false
|
||||
editable: true
|
||||
options: {path: /var/lib/grafana/dashboards}
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: https://lb:9543
|
||||
isDefault: true
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: https://lb:9643
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: https://lb:9843
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
spanStartTimeShift: '1m'
|
||||
spanEndTimeShift: '1m'
|
||||
filterByTraceID: true
|
||||
filterBySpanID: false
|
||||
@@ -0,0 +1,16 @@
|
||||
auth_enabled: false
|
||||
server: {http_listen_port: 3100}
|
||||
common:
|
||||
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}
|
||||
@@ -0,0 +1,11 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
scrape_configs:
|
||||
- job_name: otel-collector
|
||||
static_configs:
|
||||
- targets: [otel-collector:8889]
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /run/pki/ca.crt
|
||||
server_name: otel-collector
|
||||
@@ -0,0 +1,14 @@
|
||||
server: {http_listen_port: 3200, log_level: warn}
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc: {endpoint: 0.0.0.0:4317}
|
||||
http: {endpoint: 0.0.0.0:4318}
|
||||
ingester: {max_block_duration: 5m, trace_idle_period: 10s}
|
||||
compactor: {compaction: {block_retention: 24h}}
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal: {path: /var/tempo/wal}
|
||||
local: {path: /var/tempo/blocks}
|
||||
Reference in New Issue
Block a user