Use the alert function of grafana4.

  grafana

Order

The alert function is supported above version 4 of grafana, which makes it more complete to use grafana as a monitoring panel, because only the alert function can be called monitoring.

Everything docker

According tographite_dockerThis dockerfile has been modified from grafana3 to version 4:

Modify grafana

In line 35, get the GRAFA NA version 4 package instead.

# grafana
run     cd ~ &&\
    wget https://grafanarel.s3.amazonaws.com/builds/grafana_4.1.1-1484211277_amd64.deb &&\
        dpkg -i grafana_4.1.1-1484211277_amd64.deb && rm grafana_4.1.1-1484211277_amd64.deb

Add email Configuration (Optional)

If you need to turn on email alert, you need to configure email configuration in advance in dockerfile. specifically, add email configuration in grafana/config.ini file.

Notification configuration

email

Email is a more traditional alarm channel, but when using docker version of grafana, you need to configure stmp in advance, otherwise you will report an error (/var/log/grafana/grafana.log):

t=2017-01-29T07:34:35+0000 lvl=eror msg="Failed to send alert notification email" logger=alerting.notifier.email error="Grafana mailing/smtp options not configured, contact your Grafana admin"

The configuration template is as follows:

#################################### SMTP / Emailing ##########################
[smtp]
enabled = true
host = smtp.126.com:25
user = xxxxxx
password = xxxxx
;cert_file =
;key_file =
skip_verify = true
from_address = xxxxxx@126.com

[emails]
;welcome_email_on_sign_up = false

Incidentally, turn on the lower alert configuration.

#################################### Alerting ######################################
[alerting]
# Makes it possible to turn off alert rule execution.
execute_alerts = true

Test:
图片描述

When the transmission is unsuccessful, remember to go to /var/log/grafana/grafana.log to see if there are any error diaries for investigation.

slack

With slack, it’s even simpler. You don’t need to prepare the configuration items before starting, you just need to directly configure incoming webhook on the interface, which is very suitable for docker version of grafana:
图片描述

alert

There is an alert tag in the tab of each graph, which can be configured as follows:
图片描述

Remember to add notifications and you’re done.
图片描述

doc