部署安装prometheus pushgateway

  1. 下载安装包
    官方下载地址:https://prometheus.io/download/
    下载历史版本:https://github.com/prometheus/pushgateway/releases
    wget https://github.com/prometheus/pushgateway/releases/download/v1.4.2/pushgateway-1.4.2.linux-amd64.tar.gz

  2. 解压安装
    tar -xf pushgateway-1.4.2.linux-amd64.tar.gz  -C /data/app
    mv /data/app/pushgateway-1.4.2.linux-amd64/ /data/app/pushgateway
  3. 创建用户

    groupadd prometheus

    useradd prometheus -g prometheus -M -s /sbin/nologin

  1. 编写服务启动脚本

    vim /usr/lib/systemd/system/pushgateway.service
    [Unit]
    Description=pushgateway
    Documentation=https://prometheus.io/
    After=network.target

    [Service]
    Type=simple
    User=prometheus
    ExecStart=/data/app/pushgateway/pushgateway
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

  2. 服务开机自启动
    systemctl daemon-reload
    systemctl start pushgateway.service
    systemctl status pushgateway.service
    systemctl enable pushgateway.service
    systemctl is-enabled pushgateway.service

 

修改prometheus

cd prometheus
vim cfg/prometheus.yml

- job_name: 'pushgateway'
    static_configs:
    - targets: ['master.prometheus:9091']

 

重点:添加完配置之后重启prometheus服务才生效

 

 

posted @ 2022-04-15 15:04  awks  阅读(319)  评论(0)    收藏  举报