Перенесла файлы проекта из предыдущей лабораторной работы

This commit is contained in:
vasyukova
2026-11-04 22:30:42 +03:00
parent 20afc2c790
commit e9a7a7e793
70 changed files with 8588 additions and 0 deletions
@@ -0,0 +1,13 @@
apiVersion: 1
contactPoints:
- orgId: 1
name: messenger-local
receivers:
- uid: messenger-local-webhook
type: webhook
disableResolveMessage: false
settings:
# Доставка наружу не требуется; локальный no-op endpoint.
url: http://127.0.0.1:9/messenger-alerts
httpMethod: POST
@@ -0,0 +1,9 @@
apiVersion: 1
policies:
- orgId: 1
receiver: messenger-local
group_by: ['alertname']
group_wait: 10s
group_interval: 1m
repeat_interval: 4h
@@ -0,0 +1,109 @@
apiVersion: 1
groups:
- orgId: 1
name: messenger-alerts
folder: Messenger
interval: 1m
rules:
- uid: messenger-high-error-rate
title: MessengerHighErrorRate
condition: C
data:
- refId: A
relativeTimeRange:
from: 60
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: sum(rate(http_requests_total{http_status_class="5xx"}[1m])) / clamp_min(sum(rate(http_requests_total[1m])), 1e-9)
instant: true
intervalMs: 1000
maxDataPoints: 43200
range: false
refId: A
- refId: C
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
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
for: 30s
annotations:
summary: "API error rate > 5% over 1m"
description: "5xx ratio exceeds SLO 5% for 30 seconds."
runbook: "infra/runbooks/high-error-rate.md"
labels:
severity: warning
noDataState: NoData
execErrState: Error
isPaused: false
- uid: messenger-jobs-backlog-growing
title: MessengerJobsBacklogGrowing
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: sum(increase(jobs_processed_total{outcome="retry"}[10m])) - sum(increase(jobs_processed_total{outcome="success"}[10m]))
instant: true
intervalMs: 1000
maxDataPoints: 43200
range: false
refId: A
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: [5]
type: gt
operator:
type: and
query:
params: [C]
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
for: 5m
annotations:
summary: "Retries outpace successes"
description: "Worker retry count exceeds successes by >5 for 5m."
runbook: "infra/runbooks/queue-lag.md"
labels:
severity: warning
noDataState: NoData
execErrState: Error
isPaused: false
@@ -0,0 +1,84 @@
{
"uid": "messenger-lab6",
"title": "Messenger — lab6 observability",
"schemaVersion": 39,
"version": 2,
"editable": true,
"timezone": "browser",
"time": {"from": "now-30m", "to": "now"},
"templating": {
"list": [
{
"name": "service",
"type": "query",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"query": "label_values(up, job)",
"current": {"text": "otel-collector", "value": "otel-collector"}
}
]
},
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "API RPS (total)",
"gridPos": {"x": 0, "y": 0, "w": 8, "h": 8},
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [
{"expr": "sum(rate(http_requests_total[1m]))", "legendFormat": "rps", "refId": "A"}
]
},
{
"id": 2,
"type": "timeseries",
"title": "API error ratio (5xx / total)",
"gridPos": {"x": 8, "y": 0, "w": 8, "h": 8},
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [
{"expr": "sum(rate(http_requests_total{http_status_class=\"5xx\"}[5m])) / clamp_min(sum(rate(http_requests_total[5m])), 1e-9)", "legendFormat": "ratio", "refId": "A"}
]
},
{
"id": 3,
"type": "timeseries",
"title": "HTTP latency p50/p95/p99 (s)",
"gridPos": {"x": 16, "y": 0, "w": 8, "h": 8},
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [
{"expr": "histogram_quantile(0.50, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))", "legendFormat": "p50", "refId": "A"},
{"expr": "histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))", "legendFormat": "p95", "refId": "B"},
{"expr": "histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))", "legendFormat": "p99", "refId": "C"}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Jobs processed by outcome",
"gridPos": {"x": 0, "y": 8, "w": 12, "h": 8},
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [
{"expr": "sum by (outcome) (rate(jobs_processed_total[1m]))", "legendFormat": "{{outcome}}", "refId": "A"}
]
},
{
"id": 5,
"type": "timeseries",
"title": "Job duration p95 (s) by outcome",
"gridPos": {"x": 12, "y": 8, "w": 12, "h": 8},
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [
{"expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(job_processing_duration_seconds_bucket[5m])))", "legendFormat": "{{outcome}}", "refId": "A"}
]
},
{
"id": 6,
"type": "logs",
"title": "API + worker logs",
"gridPos": {"x": 0, "y": 16, "w": 24, "h": 10},
"datasource": {"type": "loki", "uid": "loki"},
"targets": [
{"expr": "{service_name=~\"messenger-api|messenger-worker|messenger-outbox\"}", "refId": "A"}
]
}
]
}
@@ -0,0 +1,9 @@
apiVersion: 1
providers:
- name: messenger
folder: Messenger
type: file
options:
path: /etc/grafana/provisioning/dashboards/json
foldersFromFilesStructure: false
@@ -0,0 +1,37 @@
apiVersion: 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=([a-f0-9]+)'
datasourceUid: tempo
url: "$${__value.raw}"
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: http://tempo:3200
editable: false
jsonData:
tracesToLogsV2:
datasourceUid: loki
tags:
- key: service.name
value: service_name
filterByTraceID: true