安装grafana:
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_6.6.1_amd64.deb
sudo dpkg -i grafana_6.6.1_amd64.deb
配置Grafana告警邮箱:
cd /etc/grafana/
vi grafana.ini
/smtp找到smtp的配置
#################################### SMTP /Emailing ##########################
[smtp]
enabled = true
host = smtp.163.com:25
user = 你的邮箱@163.com
# If the password contains # or ; you have towrap it with trippel quotes. Ex """#password;"""
password = 你的邮箱密码 //注意需要输入的是你邮箱的授权密码 如何开启授权 请看下方
;cert_file =
;key_file =
skip_verify = true
from_address = 你的邮箱@163.com
from_name = Grafana Alert
# EHLO identity in SMTP dialog (defaults toinstance_name)
;ehlo_identity = dashboard.example.com
重启服务:
service grafana-server restart
如何开启邮箱授权:
解决:(网易)进入设置==》客户端授权密码==》点击开启

开启了就可以
注意注意:设置了授权码之后就要去改代码
代码里需要我们填写的密码是授权码!!授权码!!授权码!!不是邮箱密码
所以没有改成授权码的就会报一下的错误
550 User has no permission 密码错误,应该是授权码
Grafana使用及配置:
登录http://localhost:3000,默认用户名admin,密码admin。
进入后,首先选择Data Sources,添加需要的数据源,如下图所示。
然后进入dashboard页面,创建仪表盘。我们可以通过访问https://grafana.com/dashboards来查看已经由其他用户共享的仪表盘,选取合适的使用,缩短上手时间。在这里,作者选取的是https://grafana.com/dashboards/1443这个仪表盘,该仪表盘内已经基本涵盖一个系统需要监控的相关参数。其telegraf相关配置如下:
[[inputs.net]]
# ##By default, telegraf gathers stats from any up interface (excluding loopback)
# ##Setting interfaces will tell it to gather these explicit interfaces,
# ##regardless of status.
# ##
interfaces = ["eth0,eth1,lo"]
[[inputs.cpu]]
##Whether to report per-cpu stats or not
percpu = true
##Whether to report total system cpu stats or not
totalcpu = true
## Iftrue, collect raw CPU time metrics.
collect_cpu_time = false
# Read metrics about disk usage by mountpoint
[[inputs.disk]]
## Bydefault, telegraf gather stats for all mountpoints.
##Setting mountpoints will restrict the stats to the specified mountpoints.
#mount_points = ["/"]
##Ignore some mountpoints by filesystem type. For example (dev)tmpfs (usually
##present on /run, /var/run, /dev/shm or /dev).
ignore_fs = ["tmpfs", "devtmpfs"]
设置报警接受邮箱:
点击菜单进入Alerting 的 Notification channels 添加邮箱
点击send Test
若发送成功。会提示
目标邮箱会接受到
设置报警:
在Dashboards中选择我们需要的数据源,点击edit
会报错误
Template variables are not supported in alert queries
是因为我们在查询的时候使用了模板变量,
解决方法为:新建一个不带模板变量的查询
现在就不会报错了