2023-04-03 grafana-源码编译启动及添加prometheus数据源

该文介绍了如何从源码编译Grafana9.4.7,要求Go版本为1.19。编译过程包括设置GOPROXY、执行build.sh脚本等步骤。接着,文章详细说明了配置SMTP以发送邮件报警,以及在Grafana中添加Prometheus数据源的流程。用户需提供SMTP服务器信息和授权码,并在Grafana界面配置数据源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

摘要:

记录grafana-源码编译启动及添加prometheus数据源

 

代码仓库:

 

https://github.com/adofsauron/tiflow-dev/tree/main/trunk/grafana-9.4.7

 

依赖:

必须为go1.19版本,低于此版本则编译报错

go version go1.19.2 linux/amd64

 

yum install -y yarnpkg

 

 

编译:

https://github.com/adofsauron/tiflow-dev/blob/main/trunk/grafana-9.4.7/build.sh

 

#!/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

 

在网页客户端配置要通知的邮件:

9c70de59aec285c6ff564874ee499bf4.png

 

启动:

使用缺省配置

https://github.com/adofsauron/tiflow-dev/blob/main/trunk/grafana-9.4.7/run.sh

 

./bin/linux-amd64/grafana-server  --config=./conf/defaults.ini  web &

 

登录客户端界面:

 

http://192.168.75.149:3000/

 

  1. 第一次登录时, 用默认用户名和密码登录,admin:admin
  2. 登录成功后会提示修改密码

 

4815c7476b6846e0b511d5317f084ee9.png

 

 

添加prometheus

 

添加数据 add data source

bb8100df158b4904bc05e4ab388016f5.png#pic_center

 

选择prometheus

0f4d253f833c4119807db0f7043d19a1.png#pic_center

 

添加prometheus的服务器IP地址,默认端口为9090

 01c0a1c02c5e49b0a8d367c6f3a83174.png#pic_center

 

保存完成后,在explore即可看到刚才添加的prometheus数据

0c3ea0cfa75e4268978fe487f5886247.png

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

悟世者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值