Prometheus - Installation

简介: 云原生监控方案 Prometheus 在 Kubernetes Operator的安装管理实现


image.jpeg

https://prometheus-operator.dev/

Prometheus Operator

功能

自定义资源类型,用于部署rometheus、AlertManager等组件

简化部署配置,从 Kubernetes 资源配置 Prometheus 相关功能,例如版本、持久性、保留策略。

简化监控目标配置,基于 Kuberentes 标签查询自动生成监控目标,动态服务发现。


安装

Helm:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

helm fetch prometheus-community/kube-prometheus-stack

helm install -f values.yaml  prometheus-stack prometheus-community/kube-prometheus-stack -n monitor


YAML:

git clone https://github.com/prometheus-operator/kube-prometheus.git

cd kube-prometheus && git checkout v0.7.0

# 创建 Operator 及 CRD

kubectl apply -f manifests/setup

until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done

# 等待前置条件(Operator 及 CRD )完成后在进行部署资源对象

kubectl apply -f manifests/

架构

image.jpeg

Operator 作为控制器首先会创建 Prometheus、ServiceMonitor、AlertManager、PrometheusRule等资源对象,然后会一直 Watch 这些资源对象的事件变化从而做出修正。


Prometheus

该 CRD 声明 Prometheus 在 Kubernetes 集群中运行的配置,例如持久化、副本数量等。

Operator 通过在指定的命名空间以 StatefulSet 形式部署对应资源,并且挂载同名的 Secret 对象为的配置。

根据 ServiceMonitor 生成监控目标配置,并且在 Secret 对象中更新。


ServiceMonitor

该 CRD 声明 Prometheus 如何监控一组动态的服务,使用标签进行选择那些 Service 进行监控。

按照定义的规则进行发现新的服务,从而无需重新配置。

利用 Service 中的 EndPoint 字段填充在 Prometheus Scrape Target 从而收集监控指标。


PodMonitor

该 CRD 声明 Prometheus 如何监控一组动态的 Pods,使用标签进行选择那些 Pods 进行监控。

按照定义的规则进行发现新的 Pods,从而无需重新配置。

发现的目标可以来自于任何的命名空间,PodMonitorSpec: namespaceSelector 进行约束命名空间。

与 ServiceMonitor 区别就是不需要 Service 资源对象,针对 Pods 标签进行选择。


PrometheusRule

该 CRD 声明 Prometheus 监控指标的告警规则,包括 Recording Rules 及 Alerting。

AlertManager

该 CRD 声明 AlertManager 在 Kubernetes 集群中运行的配置,例如持久化、副本数量等。

Operator 通过在指定的命名空间以 StatefulSet 形式部署对应资源,并且挂载同名的 Secret 对象为的配置。


AlertmanagerConfig

该 CRD 声明 AlertManager 如何去进行告警或者抑制,包括 Route、Receviers。

按照定义的规则进行推送到邮件、微信、钉钉、短信、电话等。


目录
相关文章
|
20天前
|
Prometheus 数据可视化 Cloud Native
Grafana 系列文章(四):Grafana Explore
Grafana 系列文章(四):Grafana Explore
Grafana 系列文章(四):Grafana Explore
|
20天前
|
消息中间件 Prometheus Kubernetes
Grafana 系列文章(二):使用 Grafana Agent 和 Grafana Tempo 进行 Tracing
Grafana 系列文章(二):使用 Grafana Agent 和 Grafana Tempo 进行 Tracing
|
20天前
|
数据可视化 API
Grafana 系列文章(七):Grafana Explore 中的 Tracing
Grafana 系列文章(七):Grafana Explore 中的 Tracing
|
20天前
|
JSON Prometheus Cloud Native
Grafana 系列文章(六):Grafana Explore 中的日志
Grafana 系列文章(六):Grafana Explore 中的日志
|
11月前
|
Prometheus Cloud Native NoSQL
【2023】Prometheus-Prometheus与Alertmanager配置详解
【2023】Prometheus-Prometheus与Alertmanager配置详解
501 0
【2023】Prometheus-Prometheus与Alertmanager配置详解
|
机器学习/深度学习 Ubuntu iOS开发
【Elastic Engineering】Beats:解密 Filebeat 中的 setup 命令
这个步骤非常重要,但是描述的内容并不是很多。为什么需要这个步骤呢?它到底能够做什么呢?
526 0
【Elastic Engineering】Beats:解密 Filebeat 中的 setup 命令
|
Shell 微服务 Perl
Istio - Installation
了解Istio 安装,以及配置详解
212 0
Istio - Installation