天天看點

Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境

提示:文章寫完後,目錄可以自動生成,如何生成可參考右邊的幫助文檔

文章目錄

  • 一、通用監控系統基礎知識以及Prometheus的概述
    • 1.監控系統的發展史:
    • 2.什麼是Prometheus?
  • 二、工作原理及适用性
    • 1.prometheus擷取資料的方式
    • 2.Prometheus 負責時序型名額資料的采集及存儲,資料的分析、聚合、可視化、告警需要安裝其他元件。
  • 三,實驗環境
    • 1.關閉防火牆和核心防護
    • 1.1Prometheus部署

一、通用監控系統基礎知識以及Prometheus的概述

1.監控系統的發展史:

SNMP時代:機器内置的SNMP

當今時代:ZABBIX、Prometheus…小米自研監控系統等。

未來的監控時代:AI…

Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境
Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境

2.什麼是Prometheus?

Prometheus是一款時序資料庫,功能并非隻作為資料庫,是一款對目标(Target)進行監控的關鍵元件。結合其他的元件(Pushgateway、Altermanager、Grafana)組成一款完整的IT監控系統。預設資料保留一個月。

時序資料:在一段時間内通過重複的測量獲得的值的集合,用圖形表示會有一個資料軸和一個時間軸。
           

二、工作原理及适用性

1.prometheus擷取資料的方式

基于Http call,從配置檔案中指定的網絡端點上周期性的擷取資料。

支援三種類型的途徑從目标上拉取資料。(被監控的對象需要安裝什麼?)

  • Exporters :官網https://prometheus.io/download/#node_exporter
  • Instrumentation :應用程式内置prometheus相容的名額格式資料
  • Pushgateway:先推送給中間器,在從中間器拉取資料
    Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境

2.Prometheus 負責時序型名額資料的采集及存儲,資料的分析、聚合、可視化、告警需要安裝其他元件。

Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境

三,實驗環境

IP位址 角色
192.168.10.129 prometheus、node1
192.168.10.135 altermanager、node2
192.168.10.131 grafana、node3

1.關閉防火牆和核心防護

systemctl stop firewalld && systemctl disable firewalld

sed -i 's/=enforcing/=disabled/g' /etc/selinux/config  && setenforce 0
           
Prometheus監控部署一、通用監控系統基礎知識以及Prometheus的概述二、工作原理及适用性三,實驗環境

1.1Prometheus部署

192.168.10.129

下載下傳prometheus

mkdir /software && cd /software

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

tar xf prometheus-2.19.0.linux-amd64.tar.gz

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

安裝prometheus:

useradd -M -s /sbin/nologin prometheus

mkdir -p /data/prometheus

chown -R prometheus:prometheus /usr/local/prometheus /data/prometheus

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

[Service]
Type=simple
Environment="GOMAXPROCS=4"
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/prometheus/prometheus \
  --config.file=/usr/local/prometheus/prometheus.yml \
  --storage.tsdb.path=/data/prometheus \
  --storage.tsdb.retention=30d \
  --web.console.libraries=/usr/local/prometheus/console_libraries \
  --web.console.templates=/usr/local/prometheus/consoles \
  --web.listen-address=0.0.0.0:9090 \
  --web.read-timeout=5m \
  --web.max-connections=10 \
  --query.max-concurrency=20 \
  --query.timeout=2m \
  --web.enable-lifecycle
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
NoNewPrivileges=true
LimitNOFILE=infinity
ReadWriteDirectories=/data/prometheus
ProtectSystem=full

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target
           

啟動prometheus:

systemctl daemon-reload

systemctl enable prometheus && systemctl start prometheus

netstat -lntp | grep prometheus

tcp6       0      0 :::9090                 :::*                    LISTEN      43742/prometheus