Prometheus Install

Posted CIAS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Prometheus Install相关的知识,希望对你有一定的参考价值。

前言

Prometheus是一个开源的系统监控和报警系统,现在已经加入到CNCF基金会,成为继k8s之后第二个在CNCF托管的项目,在kubernetes容器管理系统中,通常会搭配prometheus进行监控,同时也支持多种exporter采集数据,还支持pushgateway进行数据上报,Prometheus性能足够支撑上万台规模的集群。

Prometheus采集主机监控参考部署下载,图形生成

系统安装Grafana download
Windows参考图形生成参考win_exporter
Linux参考node_exporter
mysql参考Mysql_exporter
SQL Server参考SQL exporter
Redis 参考Redis_exporter

snmp_exporter

参考

snmp_exporter

Prometheus 一键安装Linux平台

  • 配置文件位置/usr/local/prometheus-2.37.2.linux-amd64/prometheus.yml
  • Prometheus版本定义建议选择LTS长期支持版本
vim /Prometheus.sh
#!/bin/sh
# -*- coding: utf-8 -*-
# Date: 2022/11/17

echo "download prometheus"
sleep 2
wget -N -P /root/ https://github.com/prometheus/prometheus/releases/download/v2.37.2/prometheus-2.37.2.linux-amd64.tar.gz

echo "decompression prometheus"
sleep 2
tar -zxf /root/prometheus-2.37.2.linux-amd64.tar.gz -C  /usr/local/

echo "prometheus Start Service"
sleep 2
cat >>/usr/lib/systemd/system/prometheus.service<<EOF
[Unit]
Description=prometheus
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/prometheus-2.37.2.linux-amd64/prometheus  \\
--config.file=/usr/local/prometheus-2.37.2.linux-amd64/prometheus.yml \\
--storage.tsdb.path=/var/lib/prometheus/ \\
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

echo "prometheus Example Set the automatic startup service"
sleep 2
systemctl daemon-reload && systemctl enable --now prometheus

执行一键安装

sh /Prometheus.sh

进入prometheus http://192.168.11.230:9090/ 

配置文件配置

  • /usr/local/prometheus-2.37.2.linux-amd64/prometheus.yml
scrape_configs:
  - job_name: 'web' 
    scrape_interval: 5s
    static_configs: 
      - targets: 
        - localhost:9090
      
  - job_name: 'mysql-Host-monitoring'
    scrape_interval: 5s
    static_configs:
      - targets: 
        - 192.168.11.200:9104

  - job_name: 'Windows-Host-monitoring'
    scrape_interval: 5s
    static_configs:
      - targets: 
        - 192.168.11.63:9182
      
  - job_name: 'Linux-Host-monitoring'
    scrape_interval: 5s
    static_configs:
      - targets:
        - 192.168.11.230:9100
   
  - job_name: 'Redis-monitoring'
    scrape_interval: 5s
    static_configs:
      - targets: 
        - 192.168.11.253:9121
    
  - job_name: 'SQL-monitoring'
    scrape_interval: 5s
    static_configs:
      - targets: 
        - 192.168.11.252:9399

重启服务生效

systemctl restart prometheus

prometheus采集主机情况

以上是关于Prometheus Install的主要内容,如果未能解决你的问题,请参考以下文章

docker-compose Install Prometheus

docker-compose Install Prometheus

docker-compose Install Prometheus

Proxmox VE 7.2 Install Grafana+Prometheus监控 pve-exporter

Proxmox VE 7.2 Install Grafana+Prometheus监控 pve-exporter

(4) -- Jaeger, Prometheus, Kiali, GRAFANA使用指引