Реализовать observability для лабораторной 6

This commit is contained in:
2026-11-20 17:55:23 +03:00
parent 58f3d4c457
commit 9e6428de05
50 changed files with 3573 additions and 98 deletions
@@ -0,0 +1,120 @@
apiVersion: 1
groups:
- orgId: 1
name: Messenger SLO alerts
folder: MTUSI Lab 6
interval: 10s
rules:
- uid: messenger-api-high-error-rate
title: ApiHighServerErrorRate
condition: C
data:
- refId: A
relativeTimeRange:
from: 120
to: 0
datasourceUid: prometheus
model:
datasource:
type: prometheus
uid: prometheus
editorMode: code
expr: '(sum(rate(http_server_request_count_total{service_name="messenger-api",http_route!~"/health/.*",http_response_status_class="5xx"}[2m])) / clamp_min(sum(rate(http_server_request_count_total{service_name="messenger-api",http_route!~"/health/.*"}[2m])), 0.001)) or vector(0)'
instant: true
intervalMs: 1000
maxDataPoints: 43200
range: false
refId: A
- refId: C
relativeTimeRange:
from: 0
to: 0
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: [0.05]
type: gt
operator:
type: and
query:
params: [C]
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
refId: C
type: threshold
dashboardUid: messenger-observability
panelId: 2
noDataState: OK
execErrState: Error
for: 1m
annotations:
summary: Более 5% бизнес-запросов завершаются 5xx.
runbook_url: /var/lib/grafana/runbooks/api-high-error-rate.md
labels:
service: messenger-api
severity: warning
isPaused: false
- uid: messenger-queue-oldest-growing
title: QueueOldestJobGrowing
condition: C
data:
- refId: A
relativeTimeRange:
from: 60
to: 0
datasourceUid: prometheus
model:
datasource:
type: prometheus
uid: prometheus
editorMode: code
expr: '(max(messenger_queue_oldest_age_seconds{messaging_destination_name="attachments.process"}) > 20 and max(messenger_queue_depth{messaging_destination_name="attachments.process"}) > 0) or vector(0)'
instant: true
intervalMs: 1000
maxDataPoints: 43200
range: false
refId: A
- refId: C
relativeTimeRange:
from: 0
to: 0
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: [0.5]
type: gt
operator:
type: and
query:
params: [C]
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
refId: C
type: threshold
dashboardUid: messenger-observability
panelId: 7
noDataState: OK
execErrState: Error
for: 15s
annotations:
summary: Возраст старейшей незавершённой job превысил 20 секунд.
runbook_url: /var/lib/grafana/runbooks/queue-oldest-job.md
labels:
service: messenger-worker
severity: warning
isPaused: false
@@ -0,0 +1,12 @@
apiVersion: 1
providers:
- name: Messenger
orgId: 1
folder: MTUSI Lab 6
type: file
disableDeletion: true
updateIntervalSeconds: 10
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,47 @@
apiVersion: 1
deleteDatasources:
- name: Prometheus
orgId: 1
- name: Loki
orgId: 1
- name: Tempo
orgId: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
- name: Loki
uid: loki
type: loki
access: proxy
url: http://loki:3100
editable: false
jsonData:
derivedFields:
- name: TraceID
matcherRegex: 'trace[_]?id["=: ]+([0-9a-f]{32})'
datasourceUid: tempo
url: '$${__value.raw}'
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: http://tempo:3200
editable: false
jsonData:
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: -1m
spanEndTimeShift: 1m
filterByTraceID: true
filterBySpanID: false
serviceMap:
datasourceUid: prometheus
nodeGraph:
enabled: true
@@ -0,0 +1 @@