Skip to content

Commit a0108e3

Browse files
committed
[enterprise-3.9] Clearly Specify Router Metrics file format returned
1 parent 025ad19 commit a0108e3

File tree

1 file changed

+66
-73
lines changed

1 file changed

+66
-73
lines changed

install_config/router/default_haproxy_router.adoc

+66-73
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ The following example creates a router deployment with `0` replicas and
365365
customizes the router service HTTP and HTTPS ports, then scales it
366366
appropriately (to `1` replica).
367367

368-
====
369368
----
370369
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
371370
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -374,7 +373,6 @@ $ oc scale dc/router --replicas=1
374373
----
375374
<1> Ensures exposed ports are appropriately set for routers that use the
376375
container networking mode `--host-network=false`.
377-
====
378376

379377
[IMPORTANT]
380378
====
@@ -387,12 +385,10 @@ that you use via `firewall-cmd`).
387385
The following is an example using `iptables` to open the custom router service
388386
ports.
389387

390-
====
391388
----
392389
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
393390
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
394391
----
395-
====
396392

397393
[[working-with-multiple-routers]]
398394
== Working With Multiple Routers
@@ -435,7 +431,6 @@ $ oc edit dc <deploymentConfigName>
435431
Add the `template.spec.nodeSelector` field with a key and value
436432
corresponding to the label:
437433
+
438-
====
439434
----
440435
...
441436
template:
@@ -450,7 +445,6 @@ corresponding to the label:
450445
----
451446
<1> The key and value are `router` and `first`, respectively,
452447
corresponding to the `router=first` label.
453-
====
454448

455449
[[using-router-shards]]
456450
== Using Router Shards
@@ -494,7 +488,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
494488
* `*.foo.com A IN 192.168.0.5`
495489
* `*.example.com A IN 192.168.1.9`
496490

497-
498491
*Router Sharding Examples*
499492

500493
This section describes router sharding using namespace and route labels.
@@ -657,7 +650,6 @@ Here is a convenience script *_mkshard_* that
657650
illustrates how `oc adm router`, `oc set env`, and `oc scale`
658651
can be used together to make a router shard.
659652

660-
====
661653
[source,bash]
662654
----
663655
#!/bin/bash
@@ -677,7 +669,6 @@ oc scale $dc --replicas=3 //<5>
677669
The selection expression is the value of
678670
the `ROUTE_LABELS` environment variable.
679671
<5> Scale it up.
680-
====
681672

682673
Running *_mkshard_* several times creates several routers:
683674

@@ -716,7 +707,6 @@ demonstrating how to change the selection expression.
716707
Here is a convenience script *_modshard_* that modifies
717708
an existing router to use a new selection expression:
718709

719-
====
720710
[source,bash]
721711
----
722712
#!/bin/bash
@@ -739,7 +729,6 @@ oc scale $dc --replicas=3 //<5>
739729
non-`ID` arguments to `modshard` must include the
740730
environment variable name as well as its value.
741731
<5> Scale it back up.
742-
====
743732

744733
[NOTE]
745734
====
@@ -879,12 +868,10 @@ this default routing subdomain.
879868
The following example shows how you can set the configured suffix
880869
to *v3.openshift.test*:
881870

882-
====
883871
----
884872
routingConfig:
885873
subdomain: v3.openshift.test
886874
----
887-
====
888875

889876
[NOTE]
890877
====
@@ -896,11 +883,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
896883
name] for the example of a route named *no-route-hostname* without a
897884
host name added to a namespace *mynamespace* would be:
898885

899-
====
900886
----
901887
no-route-hostname-mynamespace.v3.openshift.test
902888
----
903-
====
904889

905890
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
906891
== Forcing Route Host Names to a Custom Routing Subdomain
@@ -913,11 +898,9 @@ a route and generate one based on the template provided to the
913898
The following example runs a router, which overrides the route host names using
914899
a custom subdomain template `${name}-${namespace}.apps.example.com`.
915900

916-
====
917901
----
918902
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
919903
----
920-
====
921904

922905
[[using-wildcard-certificates]]
923906
== Using Wildcard Certificates
@@ -927,15 +910,13 @@ default certificate instead. In most cases, this certificate should be provided
927910
by a trusted certificate authority, but for convenience you can use the
928911
{product-title} CA to create the certificate. For example:
929912

930-
====
931913
----
932914
$ CA=/etc/origin/master
933915
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
934916
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
935917
--hostnames='*.cloudapps.example.com' \
936918
--cert=cloudapps.crt --key=cloudapps.key
937919
----
938-
====
939920

940921
[NOTE]
941922
====
@@ -950,19 +931,15 @@ by default *_/etc/ansible/hosts_*.
950931
The router expects the certificate and key to be in PEM format in a single
951932
file:
952933

953-
====
954934
----
955935
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
956936
----
957-
====
958937

959938
From there you can use the `--default-cert` flag:
960939

961-
====
962940
----
963941
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
964942
----
965-
====
966943

967944
[NOTE]
968945
====
@@ -1113,7 +1090,6 @@ DNS lookup:
11131090
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
11141091
----
11151092

1116-
11171093
[[using-wildcard-routes]]
11181094
== Using Wildcard Routes (for a Subdomain)
11191095

@@ -1455,18 +1431,14 @@ stack, use the `--host-network=false` option when creating the router. For
14551431
example:
14561432

14571433
ifdef::openshift-enterprise[]
1458-
====
14591434
----
14601435
$ oc adm router --service-account=router --host-network=false
14611436
----
1462-
====
14631437
endif::[]
14641438
ifdef::openshift-origin[]
1465-
====
14661439
----
14671440
$ oc adm router --service-account=router --host-network=false
14681441
----
1469-
====
14701442
endif::[]
14711443

14721444
Internally, this means the router container must publish the 80 and 443
@@ -1491,7 +1463,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
14911463
add routes across the namespaces.
14921464
====
14931465

1494-
14951466
[[exposing-the-router-metrics]]
14961467
== Exposing Router Metrics
14971468

@@ -1500,63 +1471,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
15001471
are, by default, exposed or published in
15011472
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
15021473
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1503-
Metrics are also available dirctly from the
1504-
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1474+
Metrics are also available directly from the
1475+
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1476+
or CSV download.
1477+
These metrics include the HAProxy native metrics and some controller metrics.
1478+
1479+
When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
15051480

1506-
When you create a router, as below,
1507-
====
15081481
----
15091482
$ oc adm router --service-account=router
15101483
----
1511-
====
1512-
metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1513-
====
1484+
1485+
* To extract the raw statistics in Prometheus format run the following command:
1486+
+
15141487
----
1515-
$ oc adm router --service-account=router --stats-port=0
1488+
curl <user>:<password>@<router_IP>:<STATS_PORT>
15161489
----
1517-
====
1518-
1519-
To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1520-
for the router dc and delete the following lines:
1521-
1522-
====
1490+
+
1491+
For example:
1492+
+
15231493
----
1524-
- name: ROUTER_LISTEN_ADDR
1525-
value: 0.0.0.0:1936
1526-
- name: ROUTER_METRICS_TYPE
1527-
value: haproxy
1494+
$ curl admin:[email protected]:1936/metrics
15281495
----
1529-
====
1530-
Where 1936 is the STATS_PORT value.
1531-
1532-
[NOTE]
1533-
====
1534-
The `--expose-metrics` and `--metrics-image` options are deprecated. The haproxy-exporter
1535-
side car is now integrated into the router controller so you can delete the sidecar container from existing
1536-
router deployment configs. You can continue to use the side car in existing routers. New routers use the integrated metrics.
1537-
====
1538-
1539-
1540-
You can extract the raw statistics in Prometheus format by using the following.
1541-
1542-
Information needed to access the metrics is found the router service annotations:
1543-
1544-
====
1496+
+
1497+
You can get the information you need to access the metrics from the router service annotations:
1498+
+
15451499
----
1500+
$ oc edit router service <router-service-name>
1501+
1502+
apiVersion: v1
1503+
kind: Service
15461504
metadata:
15471505
annotations:
15481506
prometheus.io/port: "1936"
15491507
prometheus.io/scrape: "true"
15501508
prometheus.openshift.io/password: IImoDqON02
15511509
prometheus.openshift.io/username: admin
15521510
----
1553-
====
1554-
1555-
The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1556-
Use the above username and password to access the metrics. The path is "/metrics".
1557-
1511+
+
1512+
The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1513+
Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1514+
+
15581515
----
1559-
$ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1516+
$ curl <user>:<password>@<router_IP>:<STATS_PORT>
15601517
for example:
15611518
$ curl admin:[email protected]:1936/metrics
15621519
...
@@ -1586,6 +1543,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
15861543
...
15871544
----
15881545

1546+
* To get metrics in a browser:
1547+
+
1548+
. Delete the following xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1549+
from the router deployment configuration file:
1550+
+
1551+
----
1552+
$ oc edit service router
1553+
1554+
- name: ROUTER_LISTEN_ADDR
1555+
value: 0.0.0.0:1936
1556+
- name: ROUTER_METRICS_TYPE
1557+
value: haproxy
1558+
----
1559+
+
1560+
. Launch the stats window using the following URL in a browser, where the `STATS_PORT` value is `1936` by default:
1561+
+
1562+
----
1563+
http://admin:<Password>@<router_IP>:<STATS_PORT>
1564+
----
1565+
+
1566+
You can get the stats in CSV format by adding `;csv` to the URL:
1567+
+
1568+
For example:
1569+
+
1570+
----
1571+
http://admin:<Password>@<router_IP>:1936;csv
1572+
----
1573+
+
1574+
To get the router IP, admin name, and password:
1575+
+
1576+
----
1577+
oc describe pod <router_pod>
1578+
----
1579+
1580+
* To suppress metrics collection:
1581+
+
1582+
----
1583+
$ oc adm router --service-account=router --stats-port=0
1584+
----
15891585

15901586
[[preventing-connection-failures-during-restarts]]
15911587
== Preventing Connection Failures During Restarts
@@ -1596,6 +1592,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
15961592
around the problem by installing `iptables` rules to prevent connections during
15971593
the reload window. However, doing so means that the router needs to run with
15981594
elevated privilege so that it can manipulate `iptables` on the host. It also
1595+
15991596
means that connections that happen during the reload are temporarily ignored and
16001597
must retransmit their connection start, lengthening the time it takes to
16011598
connect, but preventing connection failure.
@@ -1628,11 +1625,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
16281625

16291626
Set the option on the router deployment configuration:
16301627

1631-
====
16321628
----
16331629
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=true
16341630
----
1635-
====
16361631

16371632
If you used a non-default name for the router, you must change *_dc/router_*
16381633
accordingly.
@@ -1695,7 +1690,6 @@ Add *timeout http-request* to the default HAProxy router image to
16951690
protect the deployment against distributed denial-of-service (DDoS) attacks (for
16961691
example, slowloris):
16971692

1698-
====
16991693
----
17001694
# and the haproxy stats socket is available at /var/run/haproxy.stats
17011695
global
@@ -1712,7 +1706,6 @@ defaults
17121706
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
17131707
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
17141708
*an error.
1715-
====
17161709

17171710
Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
17181711
limits the amount of time a client has to send the whole HTTP request.

0 commit comments

Comments
 (0)