Prometheus 安装部署

1、下载:

下载地址:
https://prometheus.io/download/
可根据需求下载不同版本

wget https://github.com/prometheus/prometheus/releases/download/v2.39.1/prometheus-2.39.1.linux-amd64.tar.gz
tar -axvf prometheus-2.39.1.linux-amd64.tar.gz 

2、配置文件修改

这里以pulsar服务的yml 下面启动的时候会配置上这个文件,  prometheus服务就会从这个配置文件中读需要监控的机器or服务

job_name 为node的节点就是上文在服务上安装的node_exporter服务的地址

prometheus.yml

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  # scrape_timeout is set to the global default (10s).
  external_labels:
    cluster: 'bigdata-pulsar-cluster'

# Load and evaluate rules in these files every 'evaluation_interval' seconds.
# rule_files:

scrape_configs:

  - job_name: "broker"
    honor_labels: true # don't overwrite job & instance labels
    static_configs:
    - targets:
      - 'IP1:PORT'
      - 'IP2:PORT'
      ...

  - job_name: "bookie"
    honor_labels: true # don't overwrite job & instance labels
    static_configs:
    - targets:
      - 'IP1:PORT'
      - 'IP2:PORT'
     ...

  - job_name: "zookeeper"
    honor_labels: true
    static_configs:
    - targets:
      - 'IP1:PORT'
      - 'IP2:PORT'
      ...

  - job_name: "node"
    honor_labels: true # don't overwrite job & instance labels
    static_configs:
    - targets:
      - 'IP1:PORT'
     ...

3、启动

# 注册成系统服务

vim /usr/lib/systemd/system/prometheus.service 
[Unit]
Description=Prometheus
After=network.target


[Service]
ExecStart=/home/monitor/prometheus/prometheus-2.39.1.linux-amd64/prometheus --config.file "/home/monitor/prometheus/prometheus-2.39.1.linux-amd64/prometheus_pulsar.yml" --web.enable-lifecycle  --web.listen-address=:8091 --storage.tsdb.retention=30d
User=root
[Install]
WantedBy=multi-user.target


# 参数说明:
web.listen-address=:8091 指定服务的端口,默认9090
storage.tsdb.retention=30d 数据存储的时间
web.enable-lifecycle 热加载配置文件
config.file  指定yml文件的地址

# 重载/开机自启/查看状态/启动
systemctl daemon-reload
systemctl enable prometheus
systemctl status prometheus 
systemctl start prometheus 

4、测试

# 查看服务是否启动:
lsof -i:8091
ps -ef | grep prometheus

地址:
http://IP:8091/targets

你可能感兴趣的:(Prometheus 安装部署)