# Prometheus alerting rules for @goodcharge/sdk. Load with `rule_files:` in # prometheus.yml. goodcharge shows a station as red 15 minutes after its last # accepted data; these rules warn before that. groups: - name: goodcharge-sdk rules: - alert: GoodchargeStationSilent expr: >- time() - max by (station) (goodcharge_last_success_timestamp_seconds{method=~"publish|update_points|heartbeat"}) > 600 for: 1m labels: severity: warning annotations: summary: 'goodcharge station {{ $labels.station }} sent no accepted data for 10 minutes' description: 'No publish, updatePoints or heartbeat succeeded for {{ $labels.station }} in the last 10 minutes. goodcharge marks the station red after 15 minutes.' - alert: GoodchargeStationRed expr: goodcharge_station_status{dot="red"} == 1 for: 5m labels: severity: critical annotations: summary: 'goodcharge station {{ $labels.station }} is red' description: 'The last API response for {{ $labels.station }} reported a red dot: drivers see its occupancy as unknown.' - alert: GoodchargeDataRejected expr: time() - goodcharge_station_last_rejection_timestamp_seconds < 900 labels: severity: warning annotations: summary: 'goodcharge rejected data for {{ $labels.station }}' description: 'goodcharge rejected a request for {{ $labels.station }} in the last 15 minutes, including one reported right after a restart. Open the station in the operator portal to read the reason.' - alert: GoodchargeKeyRefused expr: >- increase(goodcharge_requests_total{outcome="unauthorized"}[15m]) > 0 or (goodcharge_requests_total{outcome="unauthorized"} unless goodcharge_requests_total{outcome="unauthorized"} offset 15m) labels: severity: critical annotations: summary: 'goodcharge refused the API key of {{ $labels.station }}' description: 'Requests for {{ $labels.station }} are answered unauthorized, including a first refusal right after startup: the key was regenerated or the station deleted.' - alert: GoodchargeHighErrorRate expr: >- sum by (station) (rate(goodcharge_requests_total{outcome!="ok"}[15m])) / sum by (station) (rate(goodcharge_requests_total[15m])) > 0.2 for: 10m labels: severity: warning annotations: summary: 'More than 20% of goodcharge calls fail for {{ $labels.station }}' description: 'Check goodcharge_requests_total by outcome for {{ $labels.station }}.' - alert: GoodchargeHeartbeatStopped expr: max_over_time(goodcharge_heartbeat_running[1h]) == 1 and goodcharge_heartbeat_running == 0 for: 10m labels: severity: warning annotations: summary: 'The goodcharge heartbeat stopped for {{ $labels.station }}' description: 'startHeartbeat ran for {{ $labels.station }} in the last hour and is no longer running.'