knyar / nginx-lua-prometheus

Prometheus metric library for Nginx written in Lua
MIT License
1.46k stars 231 forks source link

Alerting rules #76

Closed samber closed 4 years ago

samber commented 4 years ago

Hi there 👋

I am looking for alerting rules that fit with this exporter, in order to feed an "awesome" collection: samber/awesome-prometheus-alerts.

The goal is to offer "out-of-the-box" rules in a single place.

Anybody here has such a thing ? 🙏

I think we should cross-commit in this repo as well!

knyar commented 4 years ago

Note that this is not an exporter, it's just a metric library. Users are expected to configure metrics according to their needs.

For a few basic metrics mentioned in the README (request count and latency) you would probably want to configure alerts based on error ratio and percentile latency. For example:

  - alert: NginxTooMany500s
    expr: sum by(host, node) (rate(nginx_http_requests_total{status=~"5.."}[30m]))
      / sum by(host, node) (rate(nginx_http_requests_total[30m])) > 0.01
    annotations:
      text: Nginx for {{ $labels.host }} on {{ $labels.node }} serving more than 1% errors
  - alert: NginxLatencyHigh
    expr: histogram_quantile(0.99,
          sum(rate(nginx_http_request_duration_seconds_bucket[30m])) by (host, node, le))
          > 10
    annotations:
      text: Nginx p99 latency for {{ $labels.host }} on {{ $labels.node }} is higher than 10 seconds

I hope this helps.