概述
如何配置prometheus的Java客户端 https://blog.csdn.net/frog4/article/details/84579165
一、文档资料
1.prometheus官方http API
https://prometheus.io/docs/prometheus/1.8/querying/api/ 可以根据使用的版本选择API
2.prometheus-operator
k8s集群使用prometheus-operator做监控
文档 https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
二、访问接口
http://192.168.14.176 为k8s master节点,根据实际部署替换
prometheus-operator
prometheus-operator部署prometheus集群监控
[root@docker176 ~]# kubectl -n monitoring get pod,svc
NAME READY STATUS RESTARTS AGE
po/alertmanager-main-0 2/2 Running 2 <invalid>
po/alertmanager-main-1 2/2 Running 0 <invalid>
po/alertmanager-main-2 2/2 Running 0 <invalid>
po/grafana-2388285037-7ql1n 2/2 Running 0 <invalid>
po/kube-state-metrics-4004652727-9bvs3 1/1 Running 0 <invalid>
po/node-exporter-q0z7t 1/1 Running 0 <invalid>
po/node-exporter-zhh9f 1/1 Running 0 <invalid>
po/prometheus-k8s-0 2/2 Running 2 <invalid>
po/prometheus-k8s-1 2/2 Running 0 <invalid>
po/prometheus-operator-1217885251-p8377 1/1 Running 0 <invalid>
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/alertmanager-main 10.254.233.0 <nodes> 9093:30903/TCP <invalid>
svc/alertmanager-operated None <none> 9093/TCP,6783/TCP 10h
svc/grafana 10.254.30.106 <nodes> 3000:30902/TCP <invalid>
svc/kube-state-metrics 10.254.221.201 <none> 8080/TCP <invalid>
svc/node-exporter None <none> 9100/TCP <invalid>
svc/prometheus-k8s 10.254.182.160 <nodes> 9090:30900/TCP <invalid>
svc/prometheus-operated None <none> 9090/TCP 10h
svc/prometheus-operator 10.254.102.234 <none> 8080/TCP <invalid>
使用grafana请求
http://192.168.14.176:30902/api/datasources/proxy/1/api/v1/query_range?query=((sum(node_memory_MemTotal)%20-%20sum(node_memory_MemFree)%20-%20sum(node_memory_Buffers)%20-%20sum(node_memory_Cached))%20%2F%20sum(node_memory_MemTotal))%20*%20100&start=1550732384&end=1550810623&step=1800
直接请求prometheus
http://192.168.14.176:30900/api/v1/query_range?query=((sum(node_memory_MemTotal)%20-%20sum(node_memory_MemFree)%20-%20sum(node_memory_Buffers)%20-%20sum(node_memory_Cached))%20%2F%20sum(node_memory_MemTotal))%20*%20100&start=1550732384&end=1550810623&step=1800
上面面两个请求的结果相同
prometheus http://192.168.14.176:30900/api/v1/query_range
grafana http://192.168.14.176:30902/api/datasources/proxy/1/api/v1/query_range grafana通过k8s的datasources/proxy请求到prometheus中
三、常地址
http://192.168.14.176 为k8s master节点,根据实际部署替换
prometheus
http://192.168.14.176:30900
grafana UI
http://192.168.14.176:30902
Alertmanager
http://192.168.14.176:30903
最后
以上就是清秀大树为你收集整理的prometheus api一、文档资料二、访问接口三、常地址的全部内容,希望文章能够帮你解决prometheus api一、文档资料二、访问接口三、常地址所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复