全部结束 我对通过Prometheus Operator监视Flask的“ Hello world”应用程序的基本设置有问题。如您所能,服务监视器正被Prometheus捕获,就像它出现在UI中一样,但指标没有显示:(我不知道为什么。权限吗?
我只是将文件添加到 service_monitor_flask.yaml , flask_service.yaml , values.yaml (除serviceMonitorSelector以外的默认设置)和使用的命令:helm install prometheus stable/prometheus-operator --namespace monitoring -f values.yaml
service_monitor_flask.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: hello-flask-service-monitor
labels:
app: hello-flask-service-monitor
spec:
selector:
matchLabels:
service: hello-flask-metrics
namespaceSelector:
matchNames:
- hello-flask
# any: true
endpoints:
- port: http-metrics
interval: 15s
# scheme: http
flask_service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
service: hello-flask-metrics
name: hello-flask
spec:
ports:
- name: http-metrics
protocol: TCP
port: 5000
targetPort: metrics
selector:
app: hello-flask
values.yaml
serviceMonitorSelector: {"matchLabels":{
"app": "hello-flask-service-monitor"
}}
serviceMonitorNamespaceSelector: {}