自建的Kubernetes集群接入Prometheus监控后,无法直接通过控制台进行Prometheus相关配置,而是需要自行通过Kubectl命令方式配置Promethues.yaml、废弃指标、设置Agent副本数以及升级Helm版本。
前提条件
已接入自建的Kubernetes集群,具体操作,请参见Prometheus实例 for Kubernetes。
编辑promethues.yaml文件
配置废弃指标
当您不再需要采集某些自定义指标时,为了避免这些自定义指标继续产生费用,您可以废弃这些自定义指标。已经配置为废弃的自定义指标将不再继续产生费用。
通过创建drop-metric.yaml文件配置废弃指标。示例如下:
apiVersion: v1
kind: ConfigMap
metadata:
name: arms-prom-drop-metric
namespace: arms-prom
labels:
target: arms
type: drop-metric
data:
dropMetric: |
container_memory_rss
container_memory_failures_total
apiserver_request_total
kube_pod_container_status_waiting_reason
container_cpu_load_average_10s
container_memory_max_usage_bytes
说明
dropMetric:
之后的内容就是您需要废弃的指标,请您根据实际情况进行替换。
设置Agent副本数
若您配置的Agent副本数量不足,导致Agent不断产生内存溢出发生重启。您可以调整Agent副本数实现自动扩容。
执行以下命令调整Agent副本数。示例如下:
kubectl scale deployment arms-prometheus-ack-arms-prometheus --replicas 3 -n arms-prom
说明 命令中的
3
为当前设置的Agent副本数,请您根据实际情况进行替换,建议扩容的副本数≥3。
升级Helm版本
阿里云Prometheus监控支持升级Helm版本。查看Helm的版本信息,请参见升级Helm版本。