1. 程式人生 > 其它 >Prometheus 監控系統說明

Prometheus 監控系統說明

參考:
https://prometheus.io/docs/introduction/overview/
https://github.com/prometheus/prometheus
https://www.prometheus.wang/

Prometheus 簡介

Prometheus 是一個開源系統,監控和警報工具包最初構建於 SoundCloud。 自 2012 年成立以來,許多公司和組織都採用了 Prometheus,該專案具有非常活躍的開發者和使用者社群。它現在是一個獨立的開源專案並獨立於任何公司進行維護。 為了強調這一點,並澄清專案的治理結構,Prometheus 2016年加入了 雲原生計算基金會,作為繼 Kubernetes 之後的第二個託管專案。

Prometheus 將其指標收集並存儲為時間序列資料,即指標資訊與記錄的時間戳一起儲存,以及稱為標籤的可選鍵值對。

prometheus的主要特點是:

一個多維 資料模型, 具有由指標名稱和鍵/值對標識的時間序列資料
PromQL,一種 靈活的查詢語言 利用這個維度
不依賴分散式儲存; 單個伺服器節點是自治的
時間序列收集通過 HTTP 上的拉模型發生
推送時間序列 通過中間閘道器支援
通過服務發現或靜態配置發現目標
多種圖形和儀表板支援模式

這張圖說明了 Prometheus 的架構和一些 其生態系統組成部分:

安裝說明

prometheus-operator

參考:https://github.com/prometheus-operator/prometheus-operator

專案狀態:beta,並非所有計劃的特性都已完成。API、規範、狀態和其他面向使用者的物件可能會改變,但是以向後相容的方式。

注:專案以前被稱為coreos/prometheus-operator。

為了在Kubernetes能夠方便的管理和部署Prometheus,我們使用ConfigMap了管理Prometheus配置檔案。每次對Prometheus配置檔案進行升級時,,我們需要手動移除已經執行的Pod例項,從而讓Kubernetes可以使用最新的配置檔案建立Prometheus。 而如果當應用例項的數量更多時,通過手動的方式部署和升級Prometheus過程繁瑣並且效率低下。

從本質上來講Prometheus屬於是典型的有狀態應用,而其有包含了一些自身特有的運維管理和配置管理方式。而這些都無法通過Kubernetes原生提供的應用管理概念實現自動化。為了簡化這類應用程式的管理複雜度,CoreOS率先引入了Operator的概念,並且首先推出了針對在Kubernetes下執行和管理Etcd的Etcd Operator。並隨後推出了Prometheus Operator。

Prometheus Operator架構:

Prometheus Operator目前提供的️4類資源:

  • Prometheus:宣告式建立和管理Prometheus Server例項;
  • ServiceMonitor:負責宣告式的管理監控配置;
  • PrometheusRule:負責宣告式的管理告警配置;
  • Alertmanager:宣告式的建立和管理Alertmanager例項。

kube-prometheus

參考:https://github.com/prometheus-operator/kube-prometheus

kube-prometheus提供了基於Prometheus和Prometheus Operator的完整叢集監控堆疊的示例配置。這包括部署多個Prometheus和Alertmanager例項、用於收集節點指標的指標匯出器(如node_exporters)、將Prometheus連結到各種指標端點的抓取目標配置,以及用於通知叢集中潛在問題的示例警報規則。

常用Exporter說明

監控Node

參考:https://github.com/prometheus/node_exporter

監控網路

參考:
https://github.com/prometheus/blackbox_exporter
https://github.com/prometheus/snmp_exporter

監控MySQL

參考:https://github.com/prometheus/mysqld_exporter

監控Haproxy

參考:https://github.com/prometheus/haproxy_exporter

監控Memcached

參考:https://github.com/prometheus/memcached_exporter

監控JVM

參考:https://github.com/prometheus/jmx_exporter

監控Elasticsearch

參考:https://github.com/prometheus-community/elasticsearch_exporter

監控PostgreSQL

參考:https://github.com/prometheus-community/postgres_exporter

監控MongoDB

參考:
https://github.com/dcu/mongodb_exporter
https://github.com/percona/mongodb_exporter
https://github.com/percona/grafana-dashboards

監控K8s

下表中,梳理了監控Kubernetes叢集監控的各個維度以及策略:

作者:Varden 出處:http://www.cnblogs.com/varden/ 本文內容如有雷同,請聯絡作者! 本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連線,否則保留追究法律責任的權利。