completed lab6

This commit is contained in:
2026-11-20 17:52:56 +03:00
parent 470d9d6f1e
commit 06c8c643c3
29 changed files with 1663 additions and 54 deletions
+169
View File
@@ -0,0 +1,169 @@
{
"uid": "messenger",
"title": "Messenger observability",
"schemaVersion": 41,
"version": 1,
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
},
"panels": [
{
"id": 1,
"title": "API requests / second",
"type": "timeseries",
"datasource": {
"uid": "prometheus",
"type": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "sum by (service_instance_id) (rate(http_requests_total{route!~\"/health/.*\"}[1m]))",
"refId": "A",
"legendFormat": "{{outcome}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps"
}
}
},
{
"id": 2,
"title": "API 5xx / second",
"type": "timeseries",
"datasource": {
"uid": "prometheus",
"type": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "sum(rate(http_requests_total{status_class=\"5xx\",route!~\"/health/.*\"}[1m]))",
"refId": "A",
"legendFormat": "{{outcome}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps"
}
}
},
{
"id": 3,
"title": "API p95 duration",
"type": "timeseries",
"datasource": {
"uid": "prometheus",
"type": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_duration_seconds_bucket{route!~\"/health/.*\"}[1m])))",
"refId": "A",
"legendFormat": "{{outcome}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
}
}
},
{
"id": 4,
"title": "Worker jobs / second",
"type": "timeseries",
"datasource": {
"uid": "prometheus",
"type": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "sum by (outcome) (rate(worker_jobs_total[1m]))",
"refId": "A",
"legendFormat": "{{outcome}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops"
}
}
},
{
"id": 5,
"title": "Worker p95 duration",
"type": "timeseries",
"datasource": {
"uid": "prometheus",
"type": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "histogram_quantile(0.95, sum by (le,outcome) (rate(worker_job_duration_seconds_bucket[1m])))",
"refId": "A",
"legendFormat": "{{outcome}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
}
}
},
{
"id": 6,
"title": "API and worker structured logs",
"type": "logs",
"datasource": {
"uid": "loki",
"type": "loki"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"targets": [
{
"expr": "{service_name=~\"messenger-api|messenger-worker\"}",
"refId": "A"
}
]
}
]
}
@@ -0,0 +1,6 @@
apiVersion: 1
providers:
- name: Messenger
type: file
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,25 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
- name: Loki
uid: loki
type: loki
access: proxy
url: http://loki:3100
jsonData:
derivedFields:
- name: TraceID
matcherType: label
matcherRegex: trace_id
datasourceUid: tempo
url: '$${__value.raw}'
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: http://tempo:3200
+20
View File
@@ -0,0 +1,20 @@
global
maxconn 1024
defaults
mode http
timeout connect 2s
timeout client 30s
timeout server 30s
resolvers docker
nameserver embedded 127.0.0.11:53
hold valid 2s
frontend http
bind :8080
default_backend api
backend api
balance roundrobin
option httpchk GET /health/ready
http-check expect status 200
default-server inter 2s fall 2 rise 1 resolvers docker init-addr libc,none
server api1 api1:8080 check
server api2 api2:8080 check
+23
View File
@@ -0,0 +1,23 @@
auth_enabled: false
server:
http_listen_port: 3100
common:
path_prefix: /loki
replication_factor: 1
ring:
kvstore:
store: inmemory
schema_config:
configs:
- from: '2024-04-01'
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
storage_config:
filesystem:
directory: /loki/chunks
limits_config:
allow_structured_metadata: true
+45
View File
@@ -0,0 +1,45 @@
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 256
spike_limit_mib: 64
batch:
timeout: 2s
exporters:
prometheus:
endpoint: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true
otlphttp/loki:
endpoint: http://loki:3100/otlp
sending_queue:
queue_size: 512
retry_on_failure:
max_elapsed_time: 30s
otlp/tempo:
endpoint: tempo:4317
tls:
insecure: true
sending_queue:
queue_size: 512
retry_on_failure:
max_elapsed_time: 30s
service:
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: [otlp/tempo]
+6
View File
@@ -0,0 +1,6 @@
global:
scrape_interval: 5s
scrape_configs:
- job_name: messenger
static_configs:
- targets: ['otel-collector:8889']
+3
View File
@@ -0,0 +1,3 @@
[leveldb2]
enabled = true
dir = "/data/filer"
+20
View File
@@ -0,0 +1,20 @@
server:
http_listen_port: 3200
distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
compactor:
compaction:
block_retention: 168h