@@ -1500,109 +1500,99 @@ add routes across the namespaces.
1500
1500
[[exposing-the-router-metrics]]
1501
1501
== Exposing Router Metrics
1502
1502
1503
- Using the `--metrics-image` and `--expose-metrics` options, you can configure
1504
- the {product-title} router to run a sidecar container that exposes or publishes
1505
- router metrics for consumption by external metrics collection and aggregation
1506
- systems (e.g. Prometheus, statsd).
1507
-
1508
- Depending on your router implementation, the image is appropriately set up and
1509
- the metrics sidecar container is started when the router is deployed. For
1510
- example, the HAProxy-based router implementation defaults to using the
1511
- `prom/haproxy-exporter` image to run as a sidecar container, which can then be
1512
- used as a metrics datasource by the Prometheus server.
1513
-
1514
- [NOTE]
1515
- ====
1516
- The `--metrics-image` option overrides the defaults for HAProxy-based router
1517
- implementations and, in the case of custom implementations, enables the image to
1518
- use for a custom metrics exporter or publisher.
1519
- ====
1520
-
1521
- ifdef::openshift-enterprise[]
1522
- . Grab the HAProxy Prometheus exporter image from the Docker registry:
1523
- +
1524
- ====
1525
- ----
1526
- $ sudo docker pull prom/haproxy-exporter
1527
- ----
1528
- ====
1503
+ The
1504
+ xref:../../architecture/networking/haproxy-router.adoc#haproxy-metrics[HAProxy router metrics]
1505
+ are, by default, exposed or published in
1506
+ link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
1507
+ for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1508
+ Metrics are also available dirctly from the
1509
+ link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1529
1510
1530
- . Create the {product-title} router:
1531
- +
1511
+ When you create a router, as below,
1532
1512
====
1533
1513
----
1534
- $ oc adm router --service-account=router --expose-metrics
1514
+ $ oc adm router --service-account=router
1535
1515
----
1536
1516
====
1537
- +
1538
- Or, optionally, use the `--metrics-image` option to override the HAProxy
1539
- defaults:
1540
- +
1517
+ metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1541
1518
====
1542
1519
----
1543
- $ oc adm router --service-account=router --expose-metrics \
1544
- --metrics-image=prom/haproxy-exporter
1520
+ $ oc adm router --service-account=router --stats-port=0
1545
1521
----
1546
1522
====
1547
- endif::[]
1548
- ifdef::openshift-origin[]
1549
- . Grab the HAProxy Prometheus exporter image from the Docker registry:
1550
- +
1523
+
1524
+ To switch to the HAProxy CSV format metrics, edit the
1525
+ architecture/networking/routes.adoc
1526
+ xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1527
+ for the router dc and delete the following lines:
1528
+
1551
1529
====
1552
1530
----
1553
- $ sudo docker pull prom/haproxy-exporter
1531
+ - name: ROUTER_LISTEN_ADDR
1532
+ value: 0.0.0.0:1936
1533
+ - name: ROUTER_METRICS_TYPE
1534
+ value: haproxy
1554
1535
----
1555
1536
====
1537
+ Where 1936 is the STATS_PORT value.
1556
1538
1557
- . Create the {product-title} router:
1558
- +
1539
+ [NOTE]
1559
1540
====
1560
- ----
1561
- $ oc adm router --service-account= router --expose-metrics
1562
- ----
1541
+ The `--expose-metrics` and `--metrics-image` options are deprecated. The haproxy-exporter
1542
+ side car is now integrated into the router controller so you can delete the sidecar container from existing
1543
+ router deployment configs. You can continue to use the side car in existing routers. New routers use the integrated metrics.
1563
1544
====
1564
- +
1565
- Or, optionally, use the `--metrics-image` option to override the HAProxy
1566
- defaults:
1567
- +
1545
+
1546
+
1547
+ You can extract the raw statistics in Prometheus format by using the following.
1548
+
1549
+ Information needed to access the metrics is found the router service annotations:
1550
+
1568
1551
====
1569
1552
----
1570
- $ oc adm router --service-account=router --expose-metrics \
1571
- --metrics-image=prom/haproxy-exporter
1553
+ metadata:
1554
+ annotations:
1555
+ prometheus.io/port: "1936"
1556
+ prometheus.io/scrape: "true"
1557
+ prometheus.openshift.io/password: IImoDqON02
1558
+ prometheus.openshift.io/username: admin
1572
1559
----
1573
1560
====
1574
- endif::[]
1575
1561
1576
- . Once the haproxy-exporter containers (and your HAProxy router) have started,
1577
- point Prometheus to the sidecar container on port 9101 on the node where the
1578
- haproxy-exporter container is running:
1579
- +
1580
- ====
1581
- ----
1582
- $ haproxy_exporter_ip="<enter-ip-address-or-hostname>"
1583
- $ cat > haproxy-scraper.yml <<CFGEOF
1584
- ---
1585
- global:
1586
- scrape_interval: "60s"
1587
- scrape_timeout: "10s"
1588
- # external_labels:
1589
- # source: openshift-router
1590
-
1591
- scrape_configs:
1592
- - job_name: "haproxy"
1593
- target_groups:
1594
- - targets:
1595
- - "${haproxy_exporter_ip}:9101"
1596
- CFGEOF
1597
-
1598
- $ # And start prometheus as you would normally using the above config file.
1599
- $ echo " - Example: prometheus -config.file=haproxy-scraper.yml "
1600
- $ echo " or you can start it as a container on {product-title}!!
1562
+ The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1563
+ Use the above username and password to access the metrics. The path is "/metrics".
1601
1564
1602
- $ echo " - Once the prometheus server is up, view the {product-title} HAProxy "
1603
- $ echo " router metrics at: http://<ip>:9090/consoles/haproxy.html "
1604
1565
----
1605
- ====
1566
+ $ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1567
+ for example:
1568
+ $ curl admin:[email protected] :1936/metrics
1569
+ ...
1570
+ # HELP haproxy_backend_connections_total Total number of connections.
1571
+ # TYPE haproxy_backend_connections_total gauge
1572
+ haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route"} 0
1573
+ haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route-alt"} 0
1574
+ haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route01"} 0
1575
+ ...
1576
+ # HELP haproxy_exporter_server_threshold Number of servers tracked and the current threshold value.
1577
+ # TYPE haproxy_exporter_server_threshold gauge
1578
+ haproxy_exporter_server_threshold{type="current"} 11
1579
+ haproxy_exporter_server_threshold{type="limit"} 500
1580
+ ...
1581
+ # HELP haproxy_frontend_bytes_in_total Current total of incoming bytes.
1582
+ # TYPE haproxy_frontend_bytes_in_total gauge
1583
+ haproxy_frontend_bytes_in_total{frontend="fe_no_sni"} 0
1584
+ haproxy_frontend_bytes_in_total{frontend="fe_sni"} 0
1585
+ haproxy_frontend_bytes_in_total{frontend="public"} 119070
1586
+ ...
1587
+ # HELP haproxy_server_bytes_in_total Current total of incoming bytes.
1588
+ # TYPE haproxy_server_bytes_in_total gauge
1589
+ haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_no_sni",service=""} 0
1590
+ haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_sni",service=""} 0
1591
+ 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
1592
+ 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
1593
+ ...
1594
+ ----
1595
+
1606
1596
1607
1597
[[preventing-connection-failures-during-restarts]]
1608
1598
== Preventing Connection Failures During Restarts
0 commit comments