From a306f5ce19af1e3c8848e91eccf433e2bd5067a3 Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 25 Jun 2018 11:02:58 +0200 Subject: [PATCH 1/4] Use system_mail_from when using SMTP system configuration --- tmpl/alertmanager.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tmpl/alertmanager.yml b/tmpl/alertmanager.yml index e72e74c..9e6917e 100644 --- a/tmpl/alertmanager.yml +++ b/tmpl/alertmanager.yml @@ -10,6 +10,7 @@ global: smtp_smarthost: '%%exim_relay_smtp:465' smtp_require_tls: true %end if + smtp_from: '%%system_mail_from' %else smtp_smarthost: '%%alSMTPHost:%%alSMTPPort' smtp_from: '%%alFrom' @@ -31,8 +32,8 @@ global: #hipchat_api_url: 'https://hipchat.foobar.org/' # The directory from which notification templates are read. -templates: -- '/etc/alertmanager/template/*.tmpl' +templates: + - '/etc/alertmanager/template/*.tmpl' # The root route on which each incoming alert enters. route: @@ -54,12 +55,12 @@ route: # If an alert has successfully been sent, wait 'repeat_interval' to # resend them. - repeat_interval: 3h + repeat_interval: 3h # A default receiver receiver: %%alDefaultReceiver - # All the above attributes are inherited by all child routes and can + # All the above attributes are inherited by all child routes and can # overwritten on each. # The child route trees. @@ -119,7 +120,7 @@ route: # Inhibition rules allow to mute a set of alerts given that another alert is # firing. -# We use this to mute any warning-level notifications if the same alert is +# We use this to mute any warning-level notifications if the same alert is # already critical. inhibit_rules: - source_match: From dc43a0f26c0c5b4101812ef496f00a09ae0ad2f7 Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 25 Jun 2018 11:07:56 +0200 Subject: [PATCH 2/4] Add alerting prediction rules --- dicos/70_prometheus.xml | 7 ++++--- tmpl/predict-rules.yml | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tmpl/predict-rules.yml diff --git a/dicos/70_prometheus.xml b/dicos/70_prometheus.xml index d0044e0..ca108d3 100644 --- a/dicos/70_prometheus.xml +++ b/dicos/70_prometheus.xml @@ -1,10 +1,11 @@ - + - + + prometheus @@ -147,7 +148,7 @@ Services complèmentairse Configuration du serveur Prometheus - Configuration des jobs standards + Configuration des jobs standards Configuration SMTP pour l'envois des alertes Destinatires Rêgles de distribution simples diff --git a/tmpl/predict-rules.yml b/tmpl/predict-rules.yml new file mode 100644 index 0000000..958a587 --- /dev/null +++ b/tmpl/predict-rules.yml @@ -0,0 +1,6 @@ +groups: + - name: PredictRules + rules: + - alert: disk_full_within_6_hours + expr: predict_linear(node_filesystem_free{job="%%{job_name_node}",mountpoint="/"}[1h], 6 * 3600) < 0 + for: 5m \ No newline at end of file From b4ff9a35fd1a3024f5f4633b9152281eb7f156ed Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 26 Jun 2018 12:06:05 +0200 Subject: [PATCH 3/4] modification gestion smtpTLS et correctif chemin invalide --- tmpl/alertmanager.yml | 10 +++++----- tmpl/prometheus.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tmpl/alertmanager.yml b/tmpl/alertmanager.yml index 9e6917e..10332c5 100644 --- a/tmpl/alertmanager.yml +++ b/tmpl/alertmanager.yml @@ -4,11 +4,11 @@ global: %if %%tls_smtp == "non" smtp_smarthost: '%%exim_relay_smtp:25' %elif %%tls_smtp == "port 25" - smtp_smarthost: '%%exim_relay_smtp:25' - smtp_require_tls: true - %else - smtp_smarthost: '%%exim_relay_smtp:465' - smtp_require_tls: true + smtp_smarthost: '%%exim_relay_smtp:25' + smtp_require_tls: true + %else + smtp_smarthost: '%%exim_relay_smtp:465' + smtp_require_tls: true %end if smtp_from: '%%system_mail_from' %else diff --git a/tmpl/prometheus.yml b/tmpl/prometheus.yml index 87a0b79..f305d20 100644 --- a/tmpl/prometheus.yml +++ b/tmpl/prometheus.yml @@ -22,7 +22,7 @@ scrape_configs: - job_name: '%%job_name_node' file_sd_configs: - - files: [ "%%job_file_config/*.yml" ] +# - files: [ "%%job_file_config/*.yml" ] %if %%getVar('addTargetPrometheus','non') == 'oui' static_configs: - targets: [ "%%adresse_ip_eth0:9100"%slurp From f9cb3d35b11bdcdc8578a3c82fb19712a03f714b Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Tue, 26 Jun 2018 13:20:08 +0200 Subject: [PATCH 4/4] Adding support for mail sending from smtp gateway --- dicos/70_prometheus.xml | 1 + tmpl/grafana.ini | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dicos/70_prometheus.xml b/dicos/70_prometheus.xml index ca108d3..e5a3352 100644 --- a/dicos/70_prometheus.xml +++ b/dicos/70_prometheus.xml @@ -105,6 +105,7 @@ false + diff --git a/tmpl/grafana.ini b/tmpl/grafana.ini index ba811af..341b329 100644 --- a/tmpl/grafana.ini +++ b/tmpl/grafana.ini @@ -40,11 +40,13 @@ domain = %%grafana_domain # Redirect to correct domain if host header does not match domain # Prevents DNS rebinding attacks -;enforce_domain = false +enforce_domain = true # The full public facing url you use in browser, used for redirects and emails # If you use reverse proxy and sub path specify full url (with sub path) -;root_url = http://localhost:3000 +%if %%is_empty('grafanaRootURL') +root_url = %%grafanaRootURL +%end if # Log web requests ;router_logging = false @@ -299,18 +301,20 @@ enabled = %%grafana_auth_anonymous #################################### SMTP / Emailing ########################## [smtp] -;enabled = false -;host = localhost:25 +%if %%getVar('activer_exim_relay_smtp','non') == 'oui' +enabled = true +host = %%exim_relay_smtp:25 ;user = # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;""" ;password = ;cert_file = ;key_file = -;skip_verify = false -;from_address = admin@grafana.localhost -;from_name = Grafana +skip_verify = true +from_address = %%system_mail_from +from_name = Grafana # EHLO identity in SMTP dialog (defaults to instance_name) ;ehlo_identity = dashboard.example.com +%end if [emails] ;welcome_email_on_sign_up = false