[英]prometheus is not scraping the metrics from the app deployed on kubernetes
[英]A sample containerized application in Kubernetes unable to be shown as targets in Prometheus for scraping metrics
我的目标是重现这篇博文中的观察结果: https://medium.com/kubernetes-tutorials/monitoring-your-kubernetes-deployments-with-prometheus-5665eda54045
到目前为止,我能够在我的集群中部署示例 rpc-app 应用程序,以下显示了此应用程序的两个 pod 正在运行:
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
default rpc-app-deployment-64f456b65-5m7j5 1/1 Running 0 3h23m 10.244.0.15 my-server-ip.company.com <none> <none>
default rpc-app-deployment-64f456b65-9mnfd 1/1 Running 0 3h23m 10.244.0.14 my-server-ip.company.com <none> <none>
该应用程序公开指标并通过以下方式确认:
root@xxxxx:/u01/app/k8s # curl 10.244.0.14:8081/metrics
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
...
rpc_durations_seconds{service="uniform",quantile="0.5"} 0.0001021102787270781
rpc_durations_seconds{service="uniform",quantile="0.9"} 0.00018233200374804932
rpc_durations_seconds{service="uniform",quantile="0.99"} 0.00019828258205623097
rpc_durations_seconds_sum{service="uniform"} 6.817882693745326
rpc_durations_seconds_count{service="uniform"} 68279
我的 prometheus pod 在同一个集群中运行。 但是我在普罗米修斯中看不到任何 rpc_* 计量器。
monitoring prometheus-deployment-599bbd9457-pslwf 1/1 Running 0 30m 10.244.0.21 my-server-ip.company.com <none> <none>
在普罗米修斯 GUI
单击状态-> 服务发现,我得到了
服务发现 rpc-metrics(0 / 3 个活动目标)
单击状态 -> 目标不显示任何内容(0 个目标)
点击Status -> Configuration 内容可以看到为: https://gist.github.com/denissun/14835468be3dbef7bc924032767b9d7f
我对 Prometheus/Kubernetes 监控非常陌生,感谢您帮助解决此问题。
更新 1 - 我创建了服务
`
# cat rpc-app-service.yaml
apiVersion: v1
kind: Service
metadata:
name: rpc-app-service
labels:
app: rpc-app
spec:
ports:
- name: web
port: 8081
targetPort: 8081
protocol: TCP
nodePort: 32325
selector:
app: rpc-app
type: NodePort
# kubectl get service rpc-app-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rpc-app-service NodePort 10.110.204.119 <none> 8081:32325/TCP 9h
您是否创建了 Kubernetes 服务来公开部署?
kubectl create -f rpc-app-service.yam
Prometheus 配置监视服务端点而不是部署|Pod。
看看Prometheus Operator 。 它比在集群中运行 Prometheus 部署稍微复杂一些,但它代表了 Prometheus 最先进的部署,具有一些优雅的抽象,例如PodMonitors
和ServiceMonitors
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.