将 Prometheus作员连接到 Redis Enterprise for Kubernetes
本文介绍了如何配置 Prometheus Operator 自定义资源,以允许其从 Redis Enterprise for Kubernetes 导出指标。
| 适用于 Kubernetes 的 Redis Enterprise |
|---|
要从数据库和 Redis Enterprise 集群 (REC) 收集指标数据,您可以将 Prometheus 服务器连接到 REC 上公开的终端节点。Redis Enterprise for Kubernetes 会创建一个专用服务来公开prometheus端口 (8070) 用于数据收集。一个名为ServiceMonitor允许 Prometheus作员连接到此端口并从 Redis Enterprise 收集数据。
先决条件
在将 Redis Enterprise 连接到 Kubernetes 集群上的 Prometheus 之前,请确保您已完成以下作:
- 部署 Redis Enterprise for Kubernetes(版本 6.2.10-4 或更高版本)
- 部署 Prometheus Operator(版本 0.19.0 或更高版本)
- 创建 Redis Enterprise 集群
创建一个ServiceMonitor自定义资源
下面是一个示例ServiceMonitor自定义资源文件。通过指定服务标签 (app: redis.io/service=prom-metrics) 在selector.matchLabels部分中,您可以将 Prometheus 运算符指向正确的 Redis Enterprise 服务 (<rec_name>-prom).
您需要配置以下字段才能将 Prometheus 连接到 Redis Enterprise:
| 部分 | 田 | 价值 |
|---|---|---|
spec.endpoints |
port |
暴露端口的名称 (prometheus) |
spec.namespaceSelector |
matchNames |
REC 的命名空间 |
spec.selector |
matchLabels |
REC 服务标签 (app: redis.io/service=prom-metrics) |
在与 Redis Enterprise 集群 (REC) 相同的命名空间中应用该文件。
注意:
如果 Redis Enterprise 和 Prometheus 部署在不同的命名空间中,您还需要添加serviceMonitorNamespaceSelector字段添加到 Prometheus 资源。有关跨命名空间的更多详细信息,请参阅 Prometheus 运算符文档ServiceMonitor配置。apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: redis-enterprise
spec:
endpoints:
- interval: 15s
port: prometheus
scheme: https
tlsConfig:
insecureSkipVerify: true
namespaceSelector:
matchNames:
- <your_REC_namespace>
selector:
matchLabels:
redis.io/service: prom-metrics
For more info about configuring the ServiceMonitor resource, see the ServiceMonitorSpec API documentation.
More info
- github.com/prometheus-operator
- redis.io/docs
On this page