Kubernetes 从普罗米修斯的不同豆荚中收集指标
我想从Kubernetes的部署(有多个POD)中收集指标,其中一个指标是我的部署收到的呼叫数,我的问题是关于普罗米修斯的,我如何告诉普罗米修斯调用部署中的所有POD并从中收集指标?实现这一目标的最佳实践是什么?我强烈建议使用为您的应用程序配置Prometheus monitoring来完成所有繁重的工作 例如,部署和服务如下所示:Kubernetes 从普罗米修斯的不同豆荚中收集指标,kubernetes,containers,prometheus,Kubernetes,Containers,Prometheus,我想从Kubernetes的部署(有多个POD)中收集指标,其中一个指标是我的部署收到的呼叫数,我的问题是关于普罗米修斯的,我如何告诉普罗米修斯调用部署中的所有POD并从中收集指标?实现这一目标的最佳实践是什么?我强烈建议使用为您的应用程序配置Prometheus monitoring来完成所有繁重的工作 例如,部署和服务如下所示: apiVersion: apps/v1 kind: Deployment metadata: name: example-app spec: replica
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-app
spec:
replicas: 3
selector:
matchLabels:
app: example-app
template:
metadata:
labels:
app: example-app
spec:
containers:
- name: example-app
image: fabxc/instrumented_app
ports:
- name: web
containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: example-app
labels:
app: example-app
spec:
selector:
app: example-app
ports:
- name: web
port: 8080
您可以配置ServiceMonitor
对象,该对象将使用服务作为服务发现端点来查找部署的所有POD。这假设您的应用程序正在使用HTTP路径/metrics
公开度量
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: example-app
labels:
team: frontend
spec:
selector:
matchLabels:
app: example-app
endpoints:
- port: web
这将使普罗米修斯为您的应用程序刮取度量
您可以在此处阅读有关ServiceMonitors的更多信息:谢谢您的回答!