Prometheus_exporter安装与使用
Promethues概述:可以看一下更详细的介绍,以下为转载的博客,原文链接,支持原创,请多多支持!!:闫世成的博客园
Prometheus-node-exporter
1、简介:
- 内核公开的硬件和操作系统指标的 Prometheus 导出器,用 Go 编写,带有可插入的指标收集器。
2、安装部署:
wget https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
tar xf node_exporter-1.2.2.linux-amd64.tar.gz -C /opt/
ln -s node_exporter-1.2.2.linux-amd64 node_exporter
配置文件
cat > /usr/lib/systemd/system/node_exporter.service << EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/opt/node_exporter/node_exporter
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node_exporter
[Install]
WantedBy=default.target
EOF
systemctl start node_exporter.service
ss -lnt浏览器访问http://192.168.168.106:9100/metrics
3、浏览器访问:
http://192.168.117.128:9100/metrics
4、node_exporter黑白名单
- 黑名单:不采集某一个指标的信息
--no-collector. flag
例如不采集CPU信息
./node_exporter --no-collector.cpu
- 白名单:设置node_exporter只采集某些采集项
--collector.disable-defaults --collector.
# 只开启mem采集
./node_exporter --collector.disable-defaults --collector.meminfo
# 只开启mem 和cpu 采集
./node_exporter --collector.disable-defaults --collector.meminfo --collector.cpu
4、node_exporter各个指标含义
- 访问自身的http情况
# HELP promhttp_metric_handler_errors_total Total number of internal errors encountered by the promhttp metric handler.
# TYPE promhttp_metric_handler_errors_total counter
promhttp_metric_handler_errors_total{cause="encoding"} 0
promhttp_metric_handler_errors_total{cause="gathering"} 0
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 0
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
Prometheus监控mysql mysql_exporter是用来收集MysQL或者Mariadb数据库相关指标的,mysql_exporter需要连接到数据库并有相关权限
1、Mysql创建权限账户
1、mysql -uroot -p123456
2、CREATE USER 'zhangsan'@'localhost' IDENTIFIED BY 'super';
3、GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'zhangsan'@'localhost';
4、FLUSH PRIVILEGES;
2、部署
下载软件:
1、wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz
2、tar xf mysqld_exporter-0.13.0.linux-amd64.tar.gz -C /opt/
3、ln -s /opt/mysqld_exporter-0.13.0.linux-amd64 /opt/mysqld_exporter
3、准备启动文件
[root@ops opt]# cat /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter Exporter
Wants=network-online.target
After=network-online.target
[Service]
Environment=DATA_SOURCE_NAME=exporter:devops@tcp/
ExecStart=/opt/mysqld_exporter/mysqld_exporter
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mysqld_exporter
[Install]
WantedBy=default.target
【Prometheus_exporter安装与使用】4、启动服务
systemctl start mysqld_exporter.service
systemctl enable mysqld_exporter.service
systemctl status mysqld_exporter.service
推荐阅读
- Mac安装Chromedriver
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- MAC安装Mongo
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- react|react 安装
- VueX--VUE核心插件
- python-安装sublime遇到异常
- typeScript入门基础介绍
- 监控nginx
- 使用homeBrew|使用homeBrew 安装Goland