# HELP system_cpu_usage The "recent cpu usage"for the whole system
# TYPE system_cpu_usage gauge
system_cpu_usage 0.23587264544090683
# HELP logback_events_total Number of error level events that made it to the logs
# TYPE logback_events_total counter
logback_events_total{level="error",} 0.0
logback_events_total{level=“info”,} 557.0复制代码
推荐下载:
Spring Boot Statistics 下载完后 导入文件就可以看见类似一个这样的监控界面
最上面这一行是模板变量,可以动态选择
点击设置按钮,选择Variables,点击New可以新增变量
点击title选择Edit可以进行编辑
这里编写PromQL语句
监控报警
配置发件邮箱
vim grafana.ini 我的文件路径是/usr/local/etc/grafana/grafana.ini 配置如下:
[smtp]
enabled = true
host = smtp.qq.com:25
user = 你的QQ@qq.com
# If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
password = 邮箱口令(不是QQ密码)
;cert_file =
;key_file =
;skip_verify = false
from_address = 你的QQ@qq.com
from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
;ehlo_identity = dashboard.example.com
复制代码
这里配置的是QQ邮箱,其他邮箱同理
配置完后,重启Grafana
brew services restart grafana
复制代码
配置收件人
可以添加多个收件人,以“;”分隔
最后点击Send Test 可以收到一封测试邮件,配置成功
监控指标
需要注意的是,Prometheus不支持带有模版变量的监控设置报警,否则会提示“Template variables are not supported in alert queries”