[英]Application metrics monitoring of Kubernetes Pods
我们已经在使用节点导出器在我们的kubernetes环境中提取/收集docker / container指标。 接下来我们还希望能够收集应用程序指标(在我们的案例中由spring-actuator提供,例如http:// pod-name:8080 / prometheus )。 这通常是如何完成的,请记住我们不能将Kubernetes服务用作固定DNS名称(它们在服务后面的pod上进行负载均衡)以及pod随时消失并出现,更改其名称和可寻址性的事实?
我们最初的天真方法如下(但由于服务负载均衡,这还不够):
- job_name: 'example-service'
scheme: http
metrics_path: '/prometheus'
static_configs:
- targets: ['example-service:8080']
任何建议或例子都会非常棒。
非常感谢提前,
巴特
我在同时找到了一个例子......问题已经结束。
# Example scrape config for pods
#
# The relabeling allows the actual pod scrape endpoint to be configured via the
# following annotations:
#
# * `prometheus.io/scrape`: Only scrape pods that have a value of `true`
# * `prometheus.io/path`: If the metrics path is not `/metrics` override this.
# * `prometheus.io/port`: Scrape the pod on the indicated port instead of the default of `9102`.
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.