|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/ingress_operator.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="nw-exposing-router-metrics_{context}"] |
| 7 | += Exposing router metrics |
| 8 | + |
| 9 | +You can expose the HAProxy router metrics by default in Prometheus format on the default stats port, 1936. The external metrics collection and aggregation systems such as Prometheus can access the HAProxy router metrics. You can view the HAProxy router metrics in a browser in the HTML and comma separated values (CSV) format. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You configured your firewall to access the default stats port, 1936. |
| 14 | +
|
| 15 | +.Procedure |
| 16 | + |
| 17 | +. Get the router pod name by running the following command: |
| 18 | ++ |
| 19 | +[source,terminal] |
| 20 | +---- |
| 21 | +$ oc get pods -n openshift-ingress |
| 22 | +---- |
| 23 | ++ |
| 24 | +.Example output |
| 25 | +[source,terminal] |
| 26 | +---- |
| 27 | +NAME READY STATUS RESTARTS AGE |
| 28 | +router-default-76bfffb66c-46qwp 1/1 Running 0 11h |
| 29 | +---- |
| 30 | + |
| 31 | +. Get the router's username and password, which the router pod stores in the `/var/lib/haproxy/conf/metrics-auth/statsUsername` and `/var/lib/haproxy/conf/metrics-auth/statsPassword` files: |
| 32 | + |
| 33 | +.. Get the username by running the following command: |
| 34 | ++ |
| 35 | +[source,terminal] |
| 36 | +---- |
| 37 | +$ oc rsh <router_pod_name> cat metrics-auth/statsUsername |
| 38 | +---- |
| 39 | + |
| 40 | +.. Get the password by running the following command: |
| 41 | ++ |
| 42 | +[source,terminal] |
| 43 | +---- |
| 44 | +$ oc rsh <router_pod_name> cat metrics-auth/statsPassword |
| 45 | +---- |
| 46 | + |
| 47 | +. Get the router IP and metrics certificates by running the following command: |
| 48 | ++ |
| 49 | +[source,terminal] |
| 50 | +---- |
| 51 | +$ oc describe pod <router_pod> |
| 52 | +---- |
| 53 | + |
| 54 | +. Get the raw statistics in Prometheus format by running the following command: |
| 55 | ++ |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +$ curl -u <user>:<password> http://<router_IP>:<stats_port>/metrics |
| 59 | +---- |
| 60 | + |
| 61 | +. Access the metrics securely by running the following command: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ curl -u user:password https://<router_IP>:<stats_port>/metrics -k |
| 66 | +---- |
| 67 | + |
| 68 | +. Access the default stats port, 1936, by running the following command: |
| 69 | ++ |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +$ curl -u <user>:<password> http://<router_IP>:<stats_port>/metrics |
| 73 | +---- |
| 74 | ++ |
| 75 | +.Example output |
| 76 | +[%collapsible] |
| 77 | +==== |
| 78 | +... |
| 79 | +# HELP haproxy_backend_connections_total Total number of connections. |
| 80 | +# TYPE haproxy_backend_connections_total gauge |
| 81 | +haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route"} 0 |
| 82 | +haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route-alt"} 0 |
| 83 | +haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route01"} 0 |
| 84 | +... |
| 85 | +# HELP haproxy_exporter_server_threshold Number of servers tracked and the current threshold value. |
| 86 | +# TYPE haproxy_exporter_server_threshold gauge |
| 87 | +haproxy_exporter_server_threshold{type="current"} 11 |
| 88 | +haproxy_exporter_server_threshold{type="limit"} 500 |
| 89 | +... |
| 90 | +# HELP haproxy_frontend_bytes_in_total Current total of incoming bytes. |
| 91 | +# TYPE haproxy_frontend_bytes_in_total gauge |
| 92 | +haproxy_frontend_bytes_in_total{frontend="fe_no_sni"} 0 |
| 93 | +haproxy_frontend_bytes_in_total{frontend="fe_sni"} 0 |
| 94 | +haproxy_frontend_bytes_in_total{frontend="public"} 119070 |
| 95 | +... |
| 96 | +# HELP haproxy_server_bytes_in_total Current total of incoming bytes. |
| 97 | +# TYPE haproxy_server_bytes_in_total gauge |
| 98 | +haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_no_sni",service=""} 0 |
| 99 | +haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_sni",service=""} 0 |
| 100 | +haproxy_server_bytes_in_total{namespace="default",pod="docker-registry-5-nk5fz",route="docker-registry",server="10.130.0.89:5000",service="docker-registry"} 0 |
| 101 | +haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="hello-route",server="10.130.0.90:8080",service="hello-svc-1"} 0 |
| 102 | +... |
| 103 | +==== |
| 104 | + |
| 105 | +. Launch the stats window by entering the following URL in a browser: |
| 106 | ++ |
| 107 | +[source,terminal] |
| 108 | +---- |
| 109 | +http://<user>:<password>@<router_IP>:<stats_port> |
| 110 | +---- |
| 111 | + |
| 112 | +. Optional: Get the stats in CSV format by entering the following URL in a browser: |
| 113 | ++ |
| 114 | +[source,terminal] |
| 115 | +---- |
| 116 | +http://<user>:<password>@<router_ip>:1936/metrics;csv |
| 117 | +---- |
0 commit comments