摘要:
记录grafana-源码编译启动及添加prometheus数据源
代码仓库:
依赖:
必须为go1.19版本,低于此版本则编译报错
go version go1.19.2 linux/amd64
yum install -y yarnpkg
编译:
#!/bin/bash
go env -w GOPROXY=https://goproxy.cn,direct
chmod +x scripts/*.sh
yarn install --pure-lockfile
go mod tidy
go mod download
go mod vendor
make build
配置:
配置告警的发邮件的邮箱
修改defaults.ini
#################################### SMTP / Emailing ##########################
[smtp]
enabled = true
host = smtp.163.com:465 # 我们这里使用163的邮箱
user = xxx@163.com
password = <email password> # 使用网易邮箱的授权码
skip_verify = true
from_address = xxx@163.com
#################################### Alerting ############################
[alerting]
enabled = true
execute_alerts = true
在网页客户端配置要通知的邮件:
启动:
使用缺省配置
./bin/linux-amd64/grafana-server --config=./conf/defaults.ini web &
登录客户端界面:
http://192.168.75.149:3000/
- 第一次登录时, 用默认用户名和密码登录,admin:admin
- 登录成功后会提示修改密码
添加prometheus
添加数据 add data source
选择prometheus
添加prometheus的服务器IP地址,默认端口为9090
保存完成后,在explore即可看到刚才添加的prometheus数据