forked from mtusi2026/mtusi2026lab6
4 grade_and_report
This commit is contained in:
@@ -1,87 +1,40 @@
|
||||
{
|
||||
"annotations": {"list": []},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
|
||||
"fieldConfig": {"defaults": {"unit": "reqps"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "reqps"}},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 0},
|
||||
"id": 1,
|
||||
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(http_requests_total[1m])) by (handler)",
|
||||
"legendFormat": "{{handler}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"targets": [{"expr": "sum(rate(http_requests_total[1m])) by (handler)", "legendFormat": "{{handler}}"}],
|
||||
"title": "API RPS",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
|
||||
"fieldConfig": {"defaults": {"unit": "percentunit"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "percentunit"}},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 0},
|
||||
"id": 2,
|
||||
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(http_requests_total{status=~\"5..\"}[1m])) / sum(rate(http_requests_total[1m]))",
|
||||
"legendFormat": "5xx ratio",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"targets": [{"expr": "sum(rate(http_requests_total{status=~\"5..\"}[1m])) / sum(rate(http_requests_total[1m]))", "legendFormat": "5xx ratio"}],
|
||||
"title": "API Error Rate (5xx)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}, "overrides": []},
|
||||
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 8},
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}},
|
||||
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 0},
|
||||
"id": 3,
|
||||
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, handler))",
|
||||
"legendFormat": "p95 {{handler}}",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, handler))",
|
||||
"legendFormat": "p50 {{handler}}",
|
||||
"refId": "B"
|
||||
}
|
||||
{"expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p50"},
|
||||
{"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p95"},
|
||||
{"expr": "histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p99"}
|
||||
],
|
||||
"title": "API Duration p50/p95",
|
||||
"title": "API Duration (p50/p95/p99)",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"schemaVersion": 39,
|
||||
"tags": ["lab6"],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"current": {},
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": "Prometheus",
|
||||
"multi": false,
|
||||
"name": "DS_PROMETHEUS",
|
||||
"options": [],
|
||||
"query": "prometheus",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"skipUrlSync": false,
|
||||
"type": "datasource"
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {"from": "now-15m", "to": "now"},
|
||||
"title": "Lab6 API",
|
||||
"uid": "lab6-api",
|
||||
"version": 1
|
||||
"uid": "lab6-api"
|
||||
}
|
||||
@@ -1,66 +1,52 @@
|
||||
{
|
||||
"annotations": {"list": []},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
|
||||
"fieldConfig": {"defaults": {"unit": "short"}, "overrides": []},
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "short"}},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
|
||||
"id": 1,
|
||||
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(worker_processed_total[1m])) by (result)",
|
||||
"legendFormat": "{{result}}",
|
||||
"refId": "A"
|
||||
}
|
||||
{"expr": "sum(rate(worker_processed_total{result=\"success\"}[1m]))", "legendFormat": "Success"},
|
||||
{"expr": "sum(rate(worker_processed_total{result=\"error\"}[1m]))", "legendFormat": "Error"}
|
||||
],
|
||||
"title": "Worker Jobs (success/fail)",
|
||||
"title": "Worker Jobs (Success/Error)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}, "overrides": []},
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "s"}},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
|
||||
"id": 2,
|
||||
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, sum(rate(worker_duration_seconds_bucket[5m])) by (le))",
|
||||
"legendFormat": "p95 duration",
|
||||
"refId": "A"
|
||||
}
|
||||
{"expr": "histogram_quantile(0.50, sum(rate(worker_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p50"},
|
||||
{"expr": "histogram_quantile(0.95, sum(rate(worker_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p95"},
|
||||
{"expr": "histogram_quantile(0.99, sum(rate(worker_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p99"}
|
||||
],
|
||||
"title": "Worker Duration p95",
|
||||
"title": "Worker Duration (p50/p95/p99)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "short"}},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
|
||||
"id": 3,
|
||||
"targets": [{"expr": "sum(worker_in_flight)", "legendFormat": "In Flight"}],
|
||||
"title": "Worker Saturation (In Flight Jobs)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {"type": "prometheus", "uid": "prometheus"},
|
||||
"fieldConfig": {"defaults": {"unit": "short"}},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
|
||||
"id": 4,
|
||||
"targets": [{"expr": "sum(rabbitmq_queue_depth)", "legendFormat": "Queue Depth"}],
|
||||
"title": "Queue Depth",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"schemaVersion": 39,
|
||||
"tags": ["lab6"],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"current": {},
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": "Prometheus",
|
||||
"multi": false,
|
||||
"name": "DS_PROMETHEUS",
|
||||
"options": [],
|
||||
"query": "prometheus",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"skipUrlSync": false,
|
||||
"type": "datasource"
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {"from": "now-15m", "to": "now"},
|
||||
"title": "Lab6 Worker",
|
||||
"uid": "lab6-worker",
|
||||
"version": 1
|
||||
"uid": "lab6-worker"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
apiVersion: 1
|
||||
|
||||
groups:
|
||||
- orgId: 1
|
||||
name: "worker_alerts"
|
||||
folder: "Lab6 Alerts"
|
||||
interval: 1m
|
||||
rules:
|
||||
- uid: worker-errors
|
||||
title: "Worker Errors Detected"
|
||||
condition: C
|
||||
data:
|
||||
# A: Запрос в Prometheus
|
||||
- refId: A
|
||||
datasourceUid: "prometheus"
|
||||
model:
|
||||
expr: 'worker_processed_total{result="error"}'
|
||||
instant: true
|
||||
# B: Берем последнее значение (Reduce)
|
||||
- refId: B
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
expression: "A"
|
||||
reducer: "last"
|
||||
# C: Порог (Threshold) — если больше 0, то Firing
|
||||
- refId: C
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
expression: "B"
|
||||
type: "threshold"
|
||||
conditions:
|
||||
- evaluator:
|
||||
type: "gt"
|
||||
params: [0]
|
||||
noDataState: "NoData"
|
||||
execErrState: "Error"
|
||||
for: "0m"
|
||||
labels:
|
||||
severity: "critical"
|
||||
annotations:
|
||||
summary: "Worker has encountered errors!"
|
||||
@@ -6,6 +6,7 @@ datasources:
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
uid: prometheus
|
||||
editable: false
|
||||
|
||||
- name: Loki
|
||||
|
||||
@@ -17,13 +17,6 @@ processors:
|
||||
resourcedetection:
|
||||
detectors: [env, system]
|
||||
timeout: 2s
|
||||
# ГЛАВНОЕ: Добавляем хинт для Loki через атрибуты
|
||||
attributes:
|
||||
actions:
|
||||
# Говорим Loki: "эй, возьми ресурсный атрибут service.name и сделай из него метку"
|
||||
- key: loki.resource.labels
|
||||
value: service.name
|
||||
action: insert
|
||||
|
||||
exporters:
|
||||
prometheus:
|
||||
@@ -34,7 +27,6 @@ exporters:
|
||||
endpoint: http://loki:3100/loki/api/v1/push
|
||||
tls:
|
||||
insecure: true
|
||||
# Убираем labels, так как их больше нет в 0.95.0
|
||||
otlp/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls:
|
||||
@@ -57,5 +49,5 @@ service:
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch, resourcedetection, attributes]
|
||||
processors: [memory_limiter, batch, resourcedetection]
|
||||
exporters: [loki]
|
||||
@@ -0,0 +1,20 @@
|
||||
groups:
|
||||
- name: lab6_alerts
|
||||
rules:
|
||||
# Правило 1: Высокий процент ошибок 5xx на API
|
||||
- alert: HighErrorRate
|
||||
expr: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.05
|
||||
for: 2m
|
||||
labels:
|
||||
severity: critical
|
||||
annotations:
|
||||
summary: "High 5xx error rate detected"
|
||||
|
||||
# Правило 2: Ошибки в воркере
|
||||
- alert: WorkerErrors
|
||||
expr: worker_processed_total{result="error"} > 0
|
||||
for: 0m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "Worker errors detected"
|
||||
@@ -2,16 +2,23 @@ global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
|
||||
rule_files:
|
||||
- "alerts.yml"
|
||||
|
||||
scrape_configs:
|
||||
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
|
||||
|
||||
- job_name: "otel-collector"
|
||||
static_configs:
|
||||
- targets: ["otel-collector:8889"]
|
||||
|
||||
|
||||
- job_name: "api"
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["api1:8080", "api2:8080"]
|
||||
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
- targets: ["api1:8080", "api2:8080"]
|
||||
Reference in New Issue
Block a user