wes*_*ywh 6 kubernetes prometheus kubernetes-helm
首先对使用 helm 有点新意...
所以我正在努力获得这个的掌舵部署: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"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我查看targets
普罗米修斯的页面时,我在那里看不到它。我也没有在配置文件中看到它。所以这让我觉得这个掌舵图表没有部署相同的prometheus
图表。
所以现在的问题是,如何使用 helm chart 设置自定义抓取端点kube-prometheus-stack
。从我的阅读来看,这是我应该*使用的,对吗?
在您的 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
Run Code Online (Sandbox Code Playgroud)
您需要将your_job_name
, your_namespace
, your_port
,替换your_pod_name
为您的部署文件。在我完成上述指标并通过 helm chart 重新安装 Prometheus 之后,现在我可以看到目标,并且指标被公开。
归档时间: |
|
查看次数: |
2731 次 |
最近记录: |