zoukankan      html  css  js  c++  java
  • prometheus监控部署

    1.下载软件

    https://www.prometheus.io/download/
    

    2.创建部署路径

    1.创建路径
    mkdir -p /usr/local/prometheus/{data,logs,etc}
    mkdir -p /data/prometheus/{data,logs,etc}
    
    2.解压文件
    tar xf prometheus-2.27.1.linux-amd64.tar.gz -C /usr/local/prometheus/
    
    3.修改路径名
    cd /usr/local/prometheus/
    mv prometheus-2.27.1.linux-amd64 bin/
    
    

    3.托管到systemd

    1.在/usr/local/prometheus/etc创建prometheus.service
    [root@prometheus-17 etc]# cat prometheus.service 
    # -*- mode: conf -*-
    [Unit]
    Description=Prometheus
    Documentation=https://prometheus.io/
    After=network.target
    
    [Service]
    EnvironmentFile=-/usr/local/prometheus/etc/prometheus.env
    User=prometheus
    ExecStart=/usr/local/prometheus/bin/prometheus  --web.console.libraries=/usr/local/prometheus/bin/console_libraries --web.console.templates=/usr/local/prometheus/bin/consoles $PROMETHEUS_OPTS
    ExecReload=/bin/kill -HUP $MAINPID
    Restart=always
    LimitNOFILE=65535
    
    [Install]
    WantedBy=multi-user.target
    
    2.创建软连接
    ln -sv /usr/local/prometheus/etc/prometheus.service  /usr/lib/systemd/system/prometheus.service
    
    3.reload
    systemctl daemon-reload
    

    4.创建配置文件

    1.在/usr/local/prometheus/etc下创建prometheus.env文件,内容如下
    [root@prometheus-17 etc]# cat prometheus.env
    PROMETHEUS_OPTS='--config.file=/usr/local/prometheus/etc/prometheus.yml \
    	--storage.tsdb.path=/usr/local/prometheus/data \
    	--web.listen-address=0.0.0.0:9090 \
    	--web.enable-lifecycle'
    
    2.复制 prometheus/bin 下的 prometheus.yml ⽂件到 prometheus/etc
    
    cp /usr/local/prometheus/bin/prometheus.yml /usr/local/prometheus/etc/prometheus.yml
    
    3. 在 prometheus/etc 下创建 prom-rsyslog.conf 配置⽂件,内容如下:
    if $programname == 'prometheus' then { 
      action(type="omfile" file="/usr/local/prometheus/logs/prometheus.log")
      stop
    }
    
    4.创建软连接
    ln -sv /usr/local/prometheus/etc/prom-rsyslog.conf /etc/rsyslog.d/prom-rsyslog.conf
    
    5. 重启 rsyslog
    systemctl restart rsyslog.service
    

    5.启动服务

    1.创建用户
    useradd -M -s /sbin/nologin prometheus
    
    2.修改目录主属
    chown -R prometheus:prometheus /usr/local/prometheus
    
    3.启动服务
    systemctl start prometheus.service
    

    6.确认服务正常运行

    [root@prometheus-17 etc]# netstat  -tunlp |grep 9090
    tcp6       0      0 :::9090                 :::*                    LISTEN      8688/prometheus
    
    浏览器:http://10.0.0.17:9090
    
    

    主机数据显示: http://10.0.0.17:9090/metrics

    7.prometheus默认监控图像

  • 相关阅读:
    vc 获得文件相对路径
    C#关闭MessageBox消息框(转)
    ip地址及地理位置查询
    WinDbg关联dump文件
    国外程序员推荐:每个程序员都应读的书
    [转]史上最全的C位域总结201036 2:58:00
    android 屏幕保持唤醒 不锁屏
    [转]win7如何共享
    一些DirectUI方面的资料
    计算器程序,可以计算正实数范围内的任何数据的加减乘除括号,混合运算
  • 原文地址:https://www.cnblogs.com/w1sh/p/15589742.html
Copyright © 2011-2022 走看看