Promtheus基礎概念
監控架構
Prometheus是一款面向雲原生應用程序的開源監控工具。
- Prometheus server:採集存儲監控數據
- Prometheus targets:採集對象主要分爲兩類
2.1 各種資源或服務exporters。
2.2 Pushgateway,一些短作業將監控數據推送至Pushgateway。
Prometheus server均採取pull模式主動採集對象的指標數據。 - 服務自發現機制:如通過訪問Kubernetes集羣API Server端點,就可以動態發
現和監控集羣內資源和服務。 - Alertmanager:Prometheus server定義告警規則並應用於採集到的監控數據,
觸發告警之後推送告警信息至Alertmanager,由Alertmanager進行告警處理和
路由(支持郵件、webhook等方式)。 - 數據可視化和導出:Prometheus web控制檯和Grafana,以及API客戶端。
通過Operator部署Prometheus架構
上圖中的Operator作爲控制器會去創建Prometheus、ServiceMonitor、PodMonitor、
AlertManager以及PrometheusRule等多個CRD(CustomResourceDefinitions)資
源。
- Prometheus:作爲Prometheus Server存在。
- ServiceMonitor:以聲明方式指定應如何監視服務組。Operator根據定義自動生成
Prometheus採集配置。實際上就是exporter的各種抽象,提供metrics數據接口。
Prometheus就是通過ServiceMonitor提供的metrics數據接口去 pull 數據。 - PodMonitor:以聲明方式指定應如何監視Pod組。Operator根據定義自動生成
Prometheus採集配置。 - AlertManager:作爲AlertManager存在。
- PrometheusRule:Prometheus實例使用的報警規則文件。
未完待續。。。
參考官網:https://prometheus.io/docs/introduction/overview/