MySQL监控(二): Prometheus入门

1.官网

OpenTelemetry - CNCF
Prometheus官方文档
安装包下载页
Prometheus安装官方文档指引

2.安装mysqld_exporter
(1)下载

mysqld_exporter下载

(2)配置文件

my.cnf

[client]
host=xx.xx.xx.xx
port=31090
user=root
password=root
(3)启动

启动命令:

nohup /usr/local/liufeifei/prometheus/mysqld_exporter-0.14.0.linux-amd64/mysqld_exporter --config.my-cnf=/usr/local/liufeifei/prometheus/mysqld_exporter-0.14.0.linux-amd64/my.cnf >>mysqld_exporter.log 2>&1 &
(4)验证

默认端口9104

http://xx.xx.xx.xx:9104/metrics
在这里插入图片描述

3.安装Prometheus
(1)下载

prometheus下载
在这里插入图片描述

(2)配置文件

prometheus.yml 添加mysqld_exporter的目标地址

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: "mysql"

    static_configs:
      - targets: ["xx.xx.xx.xx:9104"]
(3)启动
nohup ./prometheus --config.file=prometheus.yml --web.enable-lifecycle >>prometheus.log 2>&1 &

在这里插入图片描述
日志输出:
在这里插入图片描述

(4)验证

Prometheus默认9090端口
访问 http://xx.xx.xx.xx:9090/
在这里插入图片描述
还有输入提示
在这里插入图片描述

(5)关闭

官方文档有提供API的形式关闭Prometheus,前提是启动参数加了–web.enable-lifecycle
Prometheus Api

http://xx.xx.xx.xx:9090/-/quit 接口
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值