forked from mtusi2026/mtusi2026lab7
lab7: TLS ко всем зависимостям и телеметрии; раздельные роли PostgreSQL (GRANT по коду), ACL Valkey, AMQPS, HTTPS S3, mTLS Collector/Prometheus/Loki/Tempo/Grafana
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
# Prometheus 3.16 (prom/prometheus:v3.16.0), lab 6: the METRICS store.
|
||||
# Prometheus 3.16 (prom/prometheus:v3.16.0), labs 6-7: the METRICS store.
|
||||
#
|
||||
# Application metrics are PUSHED by the Collector over OTLP (flag --web.enable-otlp-receiver,
|
||||
# endpoint /api/v1/otlp/v1/metrics). Prometheus derives `job` = service.name and
|
||||
# `instance` = service.instance.id from the OTLP resource, and translates the OTel names with
|
||||
# suffixes: http.server.request.duration (unit s) -> http_server_request_duration_seconds_bucket,
|
||||
# messenger.jobs.processed -> messenger_jobs_processed_total (mapping: docs/OBSERVABILITY.md).
|
||||
# The telemetry components themselves are SCRAPED (pull) below.
|
||||
# Application metrics AND the Collector's own metrics are PUSHED by the Collector over OTLP/HTTPS
|
||||
# (flag --web.enable-otlp-receiver, endpoint /api/v1/otlp/v1/metrics). Prometheus derives
|
||||
# `job` = service.name and `instance` = service.instance.id from the OTLP resource, and translates
|
||||
# the OTel names with suffixes: http.server.request.duration (unit s) ->
|
||||
# http_server_request_duration_seconds_bucket (mapping: docs/OBSERVABILITY.md).
|
||||
#
|
||||
# Lab 7: the web listener is HTTPS with a REQUIRED client certificate of the internal CA and a SAN
|
||||
# allowlist (web-config.yml): only otel-collector (push), grafana (queries) and prometheus itself
|
||||
# (self-scrape, promtool healthcheck) get in. Scrapes of Loki/Tempo use HTTPS + this server's
|
||||
# own client certificate (they require one too).
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s # alert rules: detection delay = condition + `for` + <= 15 s
|
||||
@@ -24,13 +28,19 @@ rule_files:
|
||||
- /etc/prometheus/rules/*.yml
|
||||
|
||||
scrape_configs:
|
||||
- job_name: otel-collector # otelcol_* : accepted/refused/sent/failed, queue size, RSS
|
||||
static_configs: [{targets: ["otel-collector:8888"]}]
|
||||
- job_name: prometheus
|
||||
scheme: https
|
||||
tls_config: &mtls
|
||||
ca_file: /run/secrets/internal-ca.crt
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
min_version: TLS12
|
||||
static_configs: [{targets: ["localhost:9090"]}]
|
||||
- job_name: loki
|
||||
scheme: https
|
||||
tls_config: *mtls
|
||||
static_configs: [{targets: ["loki:3100"]}]
|
||||
- job_name: tempo
|
||||
scheme: https
|
||||
tls_config: *mtls
|
||||
static_configs: [{targets: ["tempo:3200"]}]
|
||||
- job_name: grafana
|
||||
static_configs: [{targets: ["grafana:3000"]}]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# HTTP client config of the container healthcheck (`promtool check healthy`): the same mTLS as any
|
||||
# other client - Prometheus' own client certificate (SAN prometheus, in the allowlist).
|
||||
tls_config:
|
||||
ca_file: /run/secrets/internal-ca.crt
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
server_name: localhost
|
||||
@@ -78,9 +78,9 @@ groups:
|
||||
# in its bounded queue and then dropped. The application itself is not affected.
|
||||
expr: |
|
||||
sum by (exporter) (
|
||||
rate(otelcol_exporter_send_failed_spans[2m])
|
||||
or rate(otelcol_exporter_send_failed_log_records[2m])
|
||||
or rate(otelcol_exporter_send_failed_metric_points[2m])
|
||||
rate(otelcol_exporter_send_failed_spans_total[2m])
|
||||
or rate(otelcol_exporter_send_failed_log_records_total[2m])
|
||||
or rate(otelcol_exporter_send_failed_metric_points_total[2m])
|
||||
) > 0
|
||||
for: 30s
|
||||
labels:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Prometheus web listener (--web.config.file), lab 7: HTTPS + mandatory client certificate of the
|
||||
# internal CA + allowlist of client identities (SAN). A certificate of the same CA with another
|
||||
# name (api, worker, loki, ...) is refused in the TLS handshake.
|
||||
tls_server_config:
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
client_auth_type: RequireAndVerifyClientCert
|
||||
client_ca_file: /run/secrets/internal-ca.crt
|
||||
client_allowed_sans: [otel-collector, grafana, prometheus]
|
||||
min_version: TLS12
|
||||
Reference in New Issue
Block a user