[email protected]">

当前位置:网站首页>Prometheus deployment

Prometheus deployment

2022-06-24 16:37:00 kevin_ yyc

One 、 Environmental preparation

1、 Firewall configuration

 The firewall is closed here , Or you can turn on the firewall 9100、9093 port 
[[email protected] ~]# systemctl stop firewall
[[email protected] ~]# systemctl disable firewalld

2、selinux To configure

[[email protected] ~]# vim /etc/selinux/config
SELINUX=disabled
[[email protected] ~]# setenforce 0

3、 to update yum

[[email protected] ~]# yum update

Two 、Prometheus Deploy

1、 Download installation package

Download link :https://prometheus.io/download/

2、 Package decompression

tar xvfz prometheus-*.tar.gz

3、 To configure Prometheus monitor

cd prometheus-*
[[email protected] 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、 Deploy node_exporter

Download address :https://prometheus.io/download/

 Download and upload installation package :node_exporter-1.1.2.linux-amd64.tar.gz
[[email protected] prometheus]# tar -xzvf node_exporter-1.1.2.linux-amd64.tar.gz
$  To configure node Boot up 
[[email protected] node_exporter-1.1.2.linux-amd64]# sudo groupadd -r prometheus
[[email protected] node_exporter-1.1.2.linux-amd64]# sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus
[[email protected] 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
$  start-up , Check the status , Configure boot up 
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter

5、Master Node editing “prometheus.yml” increase “node_exporter”IP

[[email protected] 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、 Hot update Prometheus.yml

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

7、Web visit Prometheus Address :localhost:9090/targets

image.png
原网站

版权声明
本文为[kevin_ yyc]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210414191532436u.html