首页>资讯 > >正文

腾讯云Prometheus agent容器镜像制作_世界快播报

Dockerfile:

FROM alpineWORKDIR /opt/promeADD prometheus-agent /opt/promeADD start.sh /opt/promeRUN mkdir etc && chmod +x ./start.sh ./prometheus-agentCMD ./start.sh

start.sh

./prometheus-agent \--agent.enable-sidecar \--tencent.agent-id=${agentID} \--tencent.instance-id=${instanceID} \--tencent.endpoint=monitor.tencentcloudapi.com  \--tencent.region=${region} \--config.file=/opt/prome/etc/prometheus.yml

prometheus-agent 下载:


(资料图片仅供参考)

wget https://rig-1258344699.cos.ap-guangzhou.myqcloud.com/prometheus-agent/prometheus-agent

生成镜像:

docker build -t prome-agent:v1 .

运行:

对应环境变量替换成自己的

docker run -itd \ --name pa \ -e TENCENTCLOUD_SECRET_ID="xxxx" \ -e TENCENTCLOUD_SECRET_KEY="xxxx" \ -e agentID=agent-xxxxxx \ -e region=ap-shanghai \ -e instanceID=prom-xxxxx  \ prome-agent:v1

修改采集配置:

以下exporter可以选择其他的,测试这里直接使用腾讯云exporter

在 10.10.0.35上安装exporter 进行采集

[root@VM-0-35-centos ~]# cat exporter.yml credential:  access_key: "xxxxx"  secret_key: "xxxxxx"  region: "ap-shanghai"products:  - namespace: QCE/CVM    all_metrics: true    all_instances: true

启动(默认端口9123)

./qcloud_exporter --config.file exporter.yml

重启容器:

重启后会自动拉取promejob配置更新到/opt/prome/etc/prometheus.yml中

docker restart pa

验证

安装Grafana:

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.4.7-1.x86_64.rpmyum install grafana-enterprise-9.4.7-1.x86_64.rpm

添加prometheus源:

源信息采用Basic auth

查询cvm指标:

验证OK

标签:

相关阅读