1.1. Prometheus 安装

1.1.1. download

wget https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz

1.1.2. 解压

tar xvf prometheus-2.28.1.linux-amd64.tar.gz -C /usr/local/

mv /usr/local/prometheus-2.28.1.linux-amd64 /usr/local/prometheus

1.1.3. 编辑配置文件

vim /usr/local/prometheus/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:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_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: 'node'
    static_configs:
      - targets: ['123.123.123.123:9100']
        labels:
          instance: {name}
          scrape_interval: 10s

1.1.4. 编辑启动

mkdir /data/prometheus -p

vim /etc/systemd/system/prometheus.service
>>>
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.listen-address=:10457 --storage.tsdb.path=/data/prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target

1.1.5. 添加帐户

useradd -s /sbin/nologin -M prometheus
chown -R prometheus:prometheus /usr/local/prometheus/
chown -R prometheus:prometheus /data/prometheus

1.1.6. end

systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus

results matching ""

    No results matching ""