目录
一、Linux安装prometheus
1. 解压jar包:tar -zxvf prometheus-2.26.0.linux-amd64.tar.gz
2.修改配置文件:/home/prometheus/prometheus-2.26.0.linux-amd64/目录下的配置文件:prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/home/prometheus/prometheus-2.26.0.linux-amd64/rules/*.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
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: 'localhost_node_exporter'
scrape_interval: 10ms
static_configs:
- targets: ['localhost:9100']
- job_name: 'mysql_exporter'
static_configs:
- targets: ['localhost:9104']
- job_name: 'springboot-prometheus'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['192.168.0.3:9013']
3.启动服务:./prometheus --config.file="/home/prometheus/prometheus-2.26.0.linux-amd64/prometheus.yml" &
4.浏览器访问页面:宿主机8040映射到docker中linux容器的9090端口
二、Linux安装node_exporter
node_exporter是节点输出,意思是对服务器的监控:CPU、IRM、IO、JVM等
1.解压jar包:tar -zxvf node_exporter-1.1.2.linux-amd64.tar.gz
2.启动服务:nohup /home/node_exporter/node_exporter-1.1.2.linux-amd64/node_exporter &
3.查看启动日志:nohup
4.prometheus server中修改配置文件,监听该节点并重启:
5.查看是否监控:
三、Linux安装mysqld_exporter
mysqld_exporter是对mysql监控
1.解压jar包:tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
2.创建访问mysql的配置文件*.cnf:这里创建mysql.cnf:放置路径:/home/mysqld_exporter/mysqld_exporter-0.12.1.linux-amd64/mysql.cnf
3.启动服务:nohup /home/mysqld_exporter/mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter --config.my-cnf=/home/mysqld_exporter/mysqld_exporter-0.12.1.linux-amd64/mysql.cnf &
4.查看启动日志:nohup
5.prometheus server中修改配置文件,监听该mysql并重启:
6.查看是否监控:
四、参考资料
下载软件:https://prometheus.io/download/
安装步骤:https://www.jianshu.com/p/528aeb2328a2