Add 6 lab code

This commit is contained in:
2026-11-25 12:55:15 +03:00
parent 20afc2c790
commit f6882a77b4
56 changed files with 3570 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
groups:
- name: messenger
rules:
- record: messenger:http_error_ratio:2m
expr: |
(sum(rate(http_requests_total{service_name="messenger-api",status_class="5xx"}[2m])) or vector(0))
/ clamp_min(sum(rate(http_requests_total{service_name="messenger-api"}[2m])), 0.001)
- alert: ApiHighErrorRate
expr: messenger:http_error_ratio:2m > 0.05 and sum(increase(http_requests_total{service_name="messenger-api"}[2m])) >= 20
for: 20s
labels:
severity: warning
annotations:
summary: 'API: more than 5% server errors over 2 minutes'
description: 'SLI is 5xx / all non-health requests. At least 20 requests in the window.'
runbook: 'infra/otel/README.md#api-errors'
- alert: QueueLagHigh
expr: |
max(queue_oldest_age_seconds) > 30
and max(queue_depth) > 0
and time() - max(queue_sample_timestamp_seconds) < 15
for: 15s
labels:
severity: warning
annotations:
summary: 'Oldest queued attachment waits more than 30 seconds'
description: 'Check worker capacity/busy and job errors; backlog is sampled by dispatcher.'
runbook: 'infra/otel/README.md#queue-lag'
+69
View File
@@ -0,0 +1,69 @@
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0: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: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true
enable_open_metrics: true
metric_expiration: 30s
translation_strategy: UnderscoreEscapingWithSuffixes
otlphttp/loki:
endpoint: http://loki:3100/otlp
timeout: 2s
sending_queue:
queue_size: 32
num_consumers: 2
block_on_overflow: false
retry_on_failure:
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
otlphttp/tempo:
endpoint: http://tempo:4318
timeout: 2s
sending_queue:
queue_size: 32
num_consumers: 2
block_on_overflow: false
retry_on_failure:
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
service:
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
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]
+37
View File
@@ -0,0 +1,37 @@
auth_enabled: false
server:
http_listen_port: 3100
common:
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: 72h
otlp_config:
resource_attributes:
ignore_defaults: true
attributes_config:
- action: index_label
attributes: [service.name, deployment.environment.name]
compactor:
working_directory: /loki/compactor
retention_enabled: true
delete_request_store: filesystem
analytics:
reporting_enabled: false
+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
static_configs:
- targets: ['otel-collector:8889']
- job_name: collector
static_configs:
- targets: ['otel-collector:8888']
+23
View File
@@ -0,0 +1,23 @@
server:
http_listen_port: 3200
distributor:
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
ingester:
trace_idle_period: 10s
max_block_duration: 5m
compactor:
compaction:
block_retention: 72h
storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
usage_report:
reporting_enabled: false