[root@master1 prometheus-example]#curl http:# HELP coredns_build_info A metric with a constant '1'value labeled by version,revision,and goversion from which CoreDNS was built.# TYPE coredns_build_info gaugecoredns_build_info{goversion="go1.16.4",revision="053c4d5",version="1.8.4"}1# HELP coredns_cache_entries The number of elements in the cache.# TYPE coredns_cache_entries gaugecoredns_cache_entries{server="dns:coredns_cache_entries{server="dns:# HELP coredns_cache_misses_total The count of cache misses.# TYPE coredns_cache_misses_total counter……
[root@master1 prometheus-example]#kubectl get pods -n monitorNAMEREADYSTATUSRESTARTSAGEprometheus-698b6858c9-5xgsm1/1Running013hredis-7fb8ff6779-5ts8m2/2Running048s[root@master1 prometheus-example]#kubectl get svc -n monitorNAMETYPECLUSTER-IPEXTERNAL-IPPORT(S) AGEprometheusNodePort10.101.131.61<none>9090:32700/TCP13hredisClusterIP10.99.36.173<none>6379/TCP,9121/TCP56s
1 2 3 4 5 6 7 8 9
我们可以通过 9121 端口来校验是否能够采集到数据:
bash
➜curl10.99.36.173:9121/metrics# HELP go_gc_duration_seconds A summary of the GC invocation durations.# TYPE go_gc_duration_seconds summarygo_gc_duration_seconds{quantile="0"}0go_gc_duration_seconds{quantile="0.25"}0go_gc_duration_seconds{quantile="0.5"}0go_gc_duration_seconds{quantile="0.75"}0go_gc_duration_seconds{quantile="1"}0go_gc_duration_seconds_sum0go_gc_duration_seconds_count0......# HELP redis_up Information about the Redis instance# TYPE redis_up gaugeredis_up1# HELP redis_uptime_in_seconds uptime_in_seconds metric# TYPE redis_uptime_in_seconds gaugeredis_uptime_in_seconds100
在 Kubernetes 下,Promethues 通过与 Kubernetes API 集成,主要支持5种服务发现模式,分别是:Node、Service、Pod、Endpoints、Ingress。
我们通过 kubectl 命令可以很方便的获取到当前集群中的所有节点信息:
bash
[root@master1 prometheus-example]# kubectl get nodeNAMESTATUSROLESAGEVERSIONmaster1Readycontrol-plane,master181dv1.22.2node1Ready<none>181dv1.22.2node2Ready<none>181dv1.22.2
token就是pod里面内置的,每一个pod都有;serviceaccount->secret->tokeninsecure_skip_verify:true#加上这个:只是为了不让他校验我们访问的ip;[root@master1 ~]#kubectl get po prometheus-698b6858c9-5xgsm -nmonitor -oyaml