From 321e3f3df40477138d7e53f28c73567fc440970e Mon Sep 17 00:00:00 2001 From: Vitaly Zhuravlev Date: Wed, 11 May 2022 15:11:45 +0400 Subject: [PATCH] Add alerts to apache mixin --- .../apache-http-mixin/alerts/alerts.libsonnet | 52 +++++++++++++++++++ prometheus/apache-http-mixin/config.libsonnet | 3 ++ prometheus/apache-http-mixin/mixin.libsonnet | 2 +- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 prometheus/apache-http-mixin/alerts/alerts.libsonnet diff --git a/prometheus/apache-http-mixin/alerts/alerts.libsonnet b/prometheus/apache-http-mixin/alerts/alerts.libsonnet new file mode 100644 index 0000000..873d65b --- /dev/null +++ b/prometheus/apache-http-mixin/alerts/alerts.libsonnet @@ -0,0 +1,52 @@ +{ + prometheusAlerts+:: { + groups+: [ + { + name: 'apache-http-alerts', + rules: [ + { + alert: 'ApacheDown', + expr: 'apache_up == 0', + labels: { + severity: 'warning', + }, + annotations: { + summary: 'Apache is down.', + description: 'Apache is down on {{ $labels.instance }}.', + }, + 'for': '5m', + }, + { + alert: 'ApacheRestart', + expr: 'apache_uptime_seconds_total / 60 < 1', + labels: { + severity: 'info', + }, + annotations: { + summary: 'Apache restart.', + description: 'Apache has just been restarted.', + }, + 'for': '0', + }, + { + alert: 'ApacheWorkersLoad', + expr: ||| + (sum by (instance) (apache_workers{state="busy"}) / sum by (instance) (apache_scoreboard) ) * 100 > %(alertsWarningWorkersBusy)s + ||| % $._config, + 'for': '15m', + labels: { + severity: 'warning', + }, + annotations: { + summary: 'Apache workers load is too high.', + description: ||| + Apache workers in busy state approach the max workers count %(alertsWarningWorkersBusy)s%% workers busy on {{ $labels.instance }}. + The currect value is {{ $value }}%%. + ||| % $._config, + }, + }, + ], + }, + ], + }, +} diff --git a/prometheus/apache-http-mixin/config.libsonnet b/prometheus/apache-http-mixin/config.libsonnet index 41833d4..bf3dd11 100644 --- a/prometheus/apache-http-mixin/config.libsonnet +++ b/prometheus/apache-http-mixin/config.libsonnet @@ -4,5 +4,8 @@ dashboardPeriod: 'now-1h', dashboardTimezone: 'default', dashboardRefresh: '1m', + + // for alerts + alertsWarningWorkersBusy: '80', // % }, } diff --git a/prometheus/apache-http-mixin/mixin.libsonnet b/prometheus/apache-http-mixin/mixin.libsonnet index a82d39b..b778c9e 100644 --- a/prometheus/apache-http-mixin/mixin.libsonnet +++ b/prometheus/apache-http-mixin/mixin.libsonnet @@ -1,3 +1,3 @@ (import 'dashboards/apache-exporter-full.libsonnet') + -// (import 'alerts/alerts.libsonnet') + +(import 'alerts/alerts.libsonnet') + (import 'config.libsonnet')