Add Grafana dashboard and Prometheus alerts

Shared monitoring for any obsx service, built on the uniform built-in
metric names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
M.ShakhmatovandClaude Opus 5.5 committed 2026-10-30 00:18:43 +03:00
1 parent f7c8186040
commit 3acf207727
2 files changed
+1525

No files matched your search

+115
View File
@@ -0,0 +1,115 @@
# Prometheus alerting rules for services instrumented with obsx.
#
# Built-in obsx metrics have identical names in every service, so these rules
# work for all of them; alerts are grouped by the scrape "job" label.
# Thresholds are reasonable defaults: tune them per environment.
#
# Load with Prometheus `rule_files`, or wrap into a PrometheusRule resource
# (spec.groups = the groups below) for the Prometheus Operator.
groups:
- name: obsx-service
rules:
- alert: ServiceRestartingFrequently
expr: changes(process_start_time_seconds{job!=""}[15m]) > 2
for: 0m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }} ({{ $labels.instance }}) restarted {{ $value }} times in 15m"
- alert: HealthCheckFailing
expr: health_check_status == 0
for: 5m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: {{ $labels.kind }} check {{ $labels.check }} is failing"
description: "Inspect /readyz or /healthz on the admin port of {{ $labels.instance }}."
- name: obsx-http
rules:
- alert: HTTPServerHighErrorRate
expr: |
sum by (job) (rate(http_server_requests_total{code=~"5.."}[5m]))
/
sum by (job) (rate(http_server_requests_total[5m]))
> 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of HTTP requests fail with 5xx"
- alert: HTTPServerHighLatency
expr: |
histogram_quantile(0.99,
sum by (job, le) (rate(http_server_request_duration_seconds_bucket{route!="unmatched"}[5m]))
) > 1
for: 10m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: HTTP p99 latency is {{ $value | humanizeDuration }}"
- alert: HTTPClientHighErrorRate
expr: |
sum by (job, host) (rate(http_client_requests_total{code=~"5..|error"}[5m]))
/
sum by (job, host) (rate(http_client_requests_total[5m]))
> 0.1
for: 5m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of calls to {{ $labels.host }} fail"
- name: obsx-grpc
rules:
- alert: GRPCServerHighErrorRate
expr: |
sum by (job) (rate(grpc_server_requests_total{code=~"Unknown|DeadlineExceeded|Unimplemented|Internal|Unavailable|DataLoss"}[5m]))
/
sum by (job) (rate(grpc_server_requests_total[5m]))
> 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of gRPC calls fail with server errors"
- alert: GRPCServerHighLatency
expr: |
histogram_quantile(0.99,
sum by (job, le) (rate(grpc_server_request_duration_seconds_bucket[5m]))
) > 1
for: 10m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: gRPC p99 latency is {{ $value | humanizeDuration }}"
- alert: GRPCClientHighErrorRate
expr: |
sum by (job, service) (rate(grpc_client_requests_total{code!~"OK|Canceled|InvalidArgument|NotFound|AlreadyExists|PermissionDenied|Unauthenticated|FailedPrecondition|OutOfRange"}[5m]))
/
sum by (job, service) (rate(grpc_client_requests_total[5m]))
> 0.1
for: 5m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of calls to {{ $labels.service }} fail"
- name: obsx-operations
rules:
- alert: OperationHighErrorRate
expr: |
sum by (job, operation) (rate(operation_duration_seconds_count{status="error"}[5m]))
/
sum by (job, operation) (rate(operation_duration_seconds_count[5m]))
> 0.1
for: 10m
labels:
severity: warning
annotations:
summary: "{{ $labels.job }}: operation {{ $labels.operation }} fails {{ $value | humanizePercentage }} of the time"