首先是使用头盔的新手...
因此,我正在努力部署以下命令:https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
在kubernetes集群中以我想要的方式工作。我喜欢到目前为止所做的一切,但是如何使它刮取自定义端点?我已经看到了:https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus
在标题为“ 通过注释抓取Pod指标”的部分下。我在kubernetes中的pod部署(然后是节点端口服务)中添加了以下注释:
annotations = {
"prometheus.io/scrape" = "true"
"prometheus.io/path" = "/appMetrics/prometheusMetrics"
"prometheus.io/port" = "443"
}
但是,当我看普罗米修斯的targets
页时,在那儿看不到它。我也没有在配置文件中看到它。因此,这让我认为此掌舵图表未部署相同的prometheus
图表。
所以现在的问题是,如何使用舵图kube-prometheus-stack
设置自定义刮擦终点。根据我的阅读,这是我应该*使用的一种,对吧?
答案 0 :(得分:2)
在您的custom_values.yaml中尝试以下操作并将其应用。
prometheus:
prometheusSpec:
additionalScrapeConfigs:
- job_name: your_job_name
scrape_interval: 15s
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- your_namespace
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
- source_labels: [__address__]
action: replace
regex: ([^:]+)(?::\d+)?
replacement: ${1}:your_port
target_label: __address__
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: your_pod_name
您需要将your_job_name
,your_namespace
,your_port
,your_pod_name
替换为部署文件。在完成上述指标并按舵图重新安装Prometheus之后,现在我可以看到目标了,并且指标也暴露了。