Prometheus部署

一、环境准备

1、 防火墙配置

这里做了防火墙关闭,或者可以在防火墙开启9100、9093端口
[root@Prometheus ~]# systemctl stop firewall
[root@Prometheus ~]# systemctl disable firewalld

2、selinux配置

[root@Prometheus ~]# vim /etc/selinux/config
SELINUX=disabled
[root@Prometheus ~]# setenforce 0

3、更新yum

[root@Prometheus ~]# yum update

二、Prometheus部署

1、下载安装包

下载链接:https://prometheus.io/download/

2、包解压

tar xvfz prometheus-*.tar.gz

3、配置Prometheus监控

cd prometheus-*
[root@Prometheus prometheus-2.26.0.linux-amd64]# vi 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:
      - 172.16.1.x:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules/*_rules.yml"
  - "rules/*_alerts.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: 'linux172.16.1.4x'
    static_configs:
    - targets: ['172.16.1.4x:9100']
      labels:
        instance: linux172.16.1.4x

4、部署node_exporter

下载地址:https://prometheus.io/download/

下载上传安装包:node_exporter-1.1.2.linux-amd64.tar.gz
[root@qxxx prometheus]# tar -xzvf node_exporter-1.1.2.linux-amd64.tar.gz
$ 配置node开机自启动
[root@qxxx node_exporter-1.1.2.linux-amd64]# sudo groupadd -r prometheus
[root@qxxx node_exporter-1.1.2.linux-amd64]# sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus
[root@qxxx node_exporter-1.1.2.linux-amd64]# cat << EOF > /usr/lib/systemd/system/node_exporter.service
[Service]
User=prometheus
Group=prometheus
ExecStart=/opt/prometheus/node_exporter-1.1.2.linux-amd64/node_exporter

[Install]
WantedBy=multi-user.target

[Unit]
Description=node_exporter
After=network.target 
EOF
$ 启动,查看状态,配置开机启动
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter

5、Master节点编辑“prometheus.yml”增加“node_exporter”IP

[root@Prometheus plugins]# vi prometheus.yml
  - job_name: 'linux172.16.1.4x'
    static_configs:
    - targets: ['172.16.1.4x:9100']
      labels:
        instance: 172.16.1.4x

6、热更新Prometheus.yml

curl -XPOST http://localhost:9090/-/reload

7、Web访问Prometheus地址:localhost:9090/targets

image.png
本站文章资源均来源自网络,除非特别声明,否则均不代表站方观点,并仅供查阅,不作为任何参考依据!
如有侵权请及时跟我们联系,本站将及时删除!
如遇版权问题,请查看 本站版权声明
THE END
分享
二维码
海报
Prometheus部署
5、Master节点编辑“prometheus.yml”增加“node_exporter”IP
<<上一篇
下一篇>>