@@ -59,3 +59,64 @@ $ oc -n ns1-coo get monitoringstack
59
59
NAME AGE
60
60
example-coo-monitoring-stack 81m
61
61
----
62
+
63
+ . Run the following comand to retrieve information about the active targets from Prometheus and filter the output to list only targets labeled with `app=prometheus-coo-example-app` . This verifies which targets are discovered and actively monitored by Prometheus with this specific label.
64
+ +
65
+ [source,terminal]
66
+ ----
67
+ $ oc -n oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/targets' | jq '.data.activeTargets[].discoveredLabels | select(.__meta_kubernetes_endpoints_label_app=="prometheus-coo-example-app")'
68
+ ----
69
+ +
70
+ .Example output
71
+ [source,json]
72
+ ----
73
+ {
74
+ "__address__": "10.129.2.25:8080",
75
+ "__meta_kubernetes_endpoint_address_target_kind": "Pod",
76
+ "__meta_kubernetes_endpoint_address_target_name": "prometheus-coo-example-app-5d8cd498c7-9j2gj",
77
+ "__meta_kubernetes_endpoint_node_name": "ci-ln-8tt8vxb-72292-6cxjr-worker-a-wdfnz",
78
+ "__meta_kubernetes_endpoint_port_name": "web",
79
+ "__meta_kubernetes_endpoint_port_protocol": "TCP",
80
+ "__meta_kubernetes_endpoint_ready": "true",
81
+ "__meta_kubernetes_endpoints_annotation_endpoints_kubernetes_io_last_change_trigger_time": "2024-11-05T11:24:09Z",
82
+ "__meta_kubernetes_endpoints_annotationpresent_endpoints_kubernetes_io_last_change_trigger_time": "true",
83
+ "__meta_kubernetes_endpoints_label_app": "prometheus-coo-example-app",
84
+ "__meta_kubernetes_endpoints_labelpresent_app": "true",
85
+ "__meta_kubernetes_endpoints_name": "prometheus-coo-example-app",
86
+ "__meta_kubernetes_namespace": "ns1-coo",
87
+ "__meta_kubernetes_pod_annotation_k8s_ovn_org_pod_networks": "{\"default\":{\"ip_addresses\":[\"10.129.2.25/23\"],\"mac_address\":\"0a:58:0a:81:02:19\",\"gateway_ips\":[\"10.129.2.1\"],\"routes\":[{\"dest\":\"10.128.0.0/14\",\"nextHop\":\"10.129.2.1\"},{\"dest\":\"172.30.0.0/16\",\"nextHop\":\"10.129.2.1\"},{\"dest\":\"100.64.0.0/16\",\"nextHop\":\"10.129.2.1\"}],\"ip_address\":\"10.129.2.25/23\",\"gateway_ip\":\"10.129.2.1\",\"role\":\"primary\"}}",
88
+ "__meta_kubernetes_pod_annotation_k8s_v1_cni_cncf_io_network_status": "[{\n \"name\": \"ovn-kubernetes\",\n \"interface\": \"eth0\",\n \"ips\": [\n \"10.129.2.25\"\n ],\n \"mac\": \"0a:58:0a:81:02:19\",\n \"default\": true,\n \"dns\": {}\n}]",
89
+ "__meta_kubernetes_pod_annotation_openshift_io_scc": "restricted-v2",
90
+ "__meta_kubernetes_pod_annotation_seccomp_security_alpha_kubernetes_io_pod": "runtime/default",
91
+ "__meta_kubernetes_pod_annotationpresent_k8s_ovn_org_pod_networks": "true",
92
+ "__meta_kubernetes_pod_annotationpresent_k8s_v1_cni_cncf_io_network_status": "true",
93
+ "__meta_kubernetes_pod_annotationpresent_openshift_io_scc": "true",
94
+ "__meta_kubernetes_pod_annotationpresent_seccomp_security_alpha_kubernetes_io_pod": "true",
95
+ "__meta_kubernetes_pod_controller_kind": "ReplicaSet",
96
+ "__meta_kubernetes_pod_controller_name": "prometheus-coo-example-app-5d8cd498c7",
97
+ "__meta_kubernetes_pod_host_ip": "10.0.128.2",
98
+ "__meta_kubernetes_pod_ip": "10.129.2.25",
99
+ "__meta_kubernetes_pod_label_app": "prometheus-coo-example-app",
100
+ "__meta_kubernetes_pod_label_pod_template_hash": "5d8cd498c7",
101
+ "__meta_kubernetes_pod_labelpresent_app": "true",
102
+ "__meta_kubernetes_pod_labelpresent_pod_template_hash": "true",
103
+ "__meta_kubernetes_pod_name": "prometheus-coo-example-app-5d8cd498c7-9j2gj",
104
+ "__meta_kubernetes_pod_node_name": "ci-ln-8tt8vxb-72292-6cxjr-worker-a-wdfnz",
105
+ "__meta_kubernetes_pod_phase": "Running",
106
+ "__meta_kubernetes_pod_ready": "true",
107
+ "__meta_kubernetes_pod_uid": "054c11b6-9a76-4827-a860-47f3a4596871",
108
+ "__meta_kubernetes_service_label_app": "prometheus-coo-example-app",
109
+ "__meta_kubernetes_service_labelpresent_app": "true",
110
+ "__meta_kubernetes_service_name": "prometheus-coo-example-app",
111
+ "__metrics_path__": "/metrics",
112
+ "__scheme__": "http",
113
+ "__scrape_interval__": "30s",
114
+ "__scrape_timeout__": "10s",
115
+ "job": "serviceMonitor/ns1-coo/prometheus-coo-example-monitor/0"
116
+ }
117
+ ----
118
+ +
119
+ [NOTE]
120
+ ====
121
+ The above example uses link:https://jqlang.github.io/jq/[`jq` command-line JSON processor] to format the output for convenience.
122
+ ====
0 commit comments