Skip to content

Commit a224255

Browse files
authored
Merge pull request #10549 from mburke5678/BZ-1548500
Clearly Specify Router Metrics file format returned
2 parents eb219b4 + 82cff2a commit a224255

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

Diff for: install_config/router/default_haproxy_router.adoc

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

362-
====
363362
----
364363
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
365364
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -368,7 +367,6 @@ $ oc scale dc/router --replicas=1
368367
----
369368
<1> Ensures exposed ports are appropriately set for routers that use the
370369
container networking mode `--host-network=false`.
371-
====
372370

373371
[IMPORTANT]
374372
====
@@ -381,13 +379,10 @@ that you use via `firewall-cmd`).
381379
The following is an example using `iptables` to open the custom router service
382380
ports.
383381

384-
====
385382
----
386383
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
387384
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
388385
----
389-
====
390-
391386

392387
[[working-with-multiple-routers]]
393388
== Working With Multiple Routers
@@ -430,7 +425,6 @@ $ oc edit dc <deploymentConfigName>
430425
Add the `template.spec.nodeSelector` field with a key and value
431426
corresponding to the label:
432427
+
433-
====
434428
----
435429
...
436430
template:
@@ -445,7 +439,6 @@ corresponding to the label:
445439
----
446440
<1> The key and value are `router` and `first`, respectively,
447441
corresponding to the `router=first` label.
448-
====
449442

450443
[[using-router-shards]]
451444
== Using Router Shards
@@ -489,7 +482,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
489482
* `*.foo.com A IN 192.168.0.5`
490483
* `*.example.com A IN 192.168.1.9`
491484

492-
493485
*Router Sharding Examples*
494486

495487
This section describes router sharding using namespace and route labels.
@@ -652,7 +644,6 @@ Here is a convenience script *_mkshard_* that
652644
illustrates how `oc adm router`, `oc set env`, and `oc scale`
653645
can be used together to make a router shard.
654646

655-
====
656647
[source,bash]
657648
----
658649
#!/bin/bash
@@ -672,7 +663,6 @@ oc scale $dc --replicas=3 //<5>
672663
The selection expression is the value of
673664
the `ROUTE_LABELS` environment variable.
674665
<5> Scale it up.
675-
====
676666

677667
Running *_mkshard_* several times creates several routers:
678668

@@ -711,7 +701,6 @@ demonstrating how to change the selection expression.
711701
Here is a convenience script *_modshard_* that modifies
712702
an existing router to use a new selection expression:
713703

714-
====
715704
[source,bash]
716705
----
717706
#!/bin/bash
@@ -734,7 +723,6 @@ oc scale $dc --replicas=3 //<5>
734723
non-`ID` arguments to `modshard` must include the
735724
environment variable name as well as its value.
736725
<5> Scale it back up.
737-
====
738726

739727
[NOTE]
740728
====
@@ -874,12 +862,10 @@ this default routing subdomain.
874862
The following example shows how you can set the configured suffix
875863
to *v3.openshift.test*:
876864

877-
====
878865
----
879866
routingConfig:
880867
subdomain: v3.openshift.test
881868
----
882-
====
883869

884870
[NOTE]
885871
====
@@ -891,11 +877,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
891877
name] for the example of a route named *no-route-hostname* without a
892878
host name added to a namespace *mynamespace* would be:
893879

894-
====
895880
----
896881
no-route-hostname-mynamespace.v3.openshift.test
897882
----
898-
====
899883

900884
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
901885
== Forcing Route Host Names to a Custom Routing Subdomain
@@ -908,11 +892,9 @@ a route and generate one based on the template provided to the
908892
The following example runs a router, which overrides the route host names using
909893
a custom subdomain template `${name}-${namespace}.apps.example.com`.
910894

911-
====
912895
----
913896
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
914897
----
915-
====
916898

917899
[[using-wildcard-certificates]]
918900
== Using Wildcard Certificates
@@ -922,15 +904,13 @@ default certificate instead. In most cases, this certificate should be provided
922904
by a trusted certificate authority, but for convenience you can use the
923905
{product-title} CA to create the certificate. For example:
924906

925-
====
926907
----
927908
$ CA=/etc/origin/master
928909
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
929910
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
930911
--hostnames='*.cloudapps.example.com' \
931912
--cert=cloudapps.crt --key=cloudapps.key
932913
----
933-
====
934914

935915
[NOTE]
936916
====
@@ -945,19 +925,15 @@ by default *_/etc/ansible/hosts_*.
945925
The router expects the certificate and key to be in PEM format in a single
946926
file:
947927

948-
====
949928
----
950929
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
951930
----
952-
====
953931

954932
From there you can use the `--default-cert` flag:
955933

956-
====
957934
----
958935
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
959936
----
960-
====
961937

962938
[NOTE]
963939
====
@@ -1108,7 +1084,6 @@ DNS lookup:
11081084
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
11091085
----
11101086

1111-
11121087
[[using-wildcard-routes]]
11131088
== Using Wildcard Routes (for a Subdomain)
11141089

@@ -1450,18 +1425,14 @@ stack, use the `--host-network=false` option when creating the router. For
14501425
example:
14511426

14521427
ifdef::openshift-enterprise[]
1453-
====
14541428
----
14551429
$ oc adm router --service-account=router --host-network=false
14561430
----
1457-
====
14581431
endif::[]
14591432
ifdef::openshift-origin[]
1460-
====
14611433
----
14621434
$ oc adm router --service-account=router --host-network=false
14631435
----
1464-
====
14651436
endif::[]
14661437

14671438
Internally, this means the router container must publish the 80 and 443
@@ -1486,7 +1457,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
14861457
add routes across the namespaces.
14871458
====
14881459

1489-
14901460
[[exposing-the-router-metrics]]
14911461
== Exposing Router Metrics
14921462

@@ -1495,55 +1465,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
14951465
are, by default, exposed or published in
14961466
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
14971467
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1498-
Metrics are also available dirctly from the
1499-
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1468+
Metrics are also available directly from the
1469+
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1470+
or CSV download.
1471+
These metrics include the HAProxy native metrics and some controller metrics.
1472+
1473+
When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
15001474

1501-
When you create a router, as below,
1502-
====
15031475
----
15041476
$ oc adm router --service-account=router
15051477
----
1506-
====
1507-
metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1508-
====
1478+
1479+
* To extract the raw statistics in Prometheus format run the following command:
1480+
+
15091481
----
1510-
$ oc adm router --service-account=router --stats-port=0
1482+
curl <user>:<password>@<router_IP>:<STATS_PORT>
15111483
----
1512-
====
1513-
1514-
To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1515-
for the router dc and delete the following lines:
1516-
1517-
====
1484+
+
1485+
For example:
1486+
+
15181487
----
1519-
- name: ROUTER_LISTEN_ADDR
1520-
value: 0.0.0.0:1936
1521-
- name: ROUTER_METRICS_TYPE
1522-
value: haproxy
1488+
$ curl admin:[email protected]:1936/metrics
15231489
----
1524-
====
1525-
Where 1936 is the STATS_PORT value.
1526-
1527-
You can extract the raw statistics in Prometheus format by using the following.
1528-
1529-
Information needed to access the metrics is found the router service annotations:
1530-
1531-
====
1490+
+
1491+
You can get the information you need to access the metrics from the router service annotations:
1492+
+
15321493
----
1494+
$ oc edit router service <router-service-name>
1495+
1496+
apiVersion: v1
1497+
kind: Service
15331498
metadata:
15341499
annotations:
15351500
prometheus.io/port: "1936"
15361501
prometheus.io/scrape: "true"
15371502
prometheus.openshift.io/password: IImoDqON02
15381503
prometheus.openshift.io/username: admin
15391504
----
1540-
====
1541-
1542-
The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1543-
Use the above username and password to access the metrics. The path is "/metrics".
1544-
1505+
+
1506+
The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1507+
Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1508+
+
15451509
----
1546-
$ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1510+
$ curl <user>:<password>@<router_IP>:<STATS_PORT>
15471511
for example:
15481512
$ curl admin:[email protected]:1936/metrics
15491513
...
@@ -1573,6 +1537,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
15731537
...
15741538
----
15751539

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

15771580
[[preventing-connection-failures-during-restarts]]
15781581
== Preventing Connection Failures During Restarts
@@ -1583,6 +1586,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
15831586
around the problem by installing `iptables` rules to prevent connections during
15841587
the reload window. However, doing so means that the router needs to run with
15851588
elevated privilege so that it can manipulate `iptables` on the host. It also
1589+
15861590
means that connections that happen during the reload are temporarily ignored and
15871591
must retransmit their connection start, lengthening the time it takes to
15881592
connect, but preventing connection failure.
@@ -1615,11 +1619,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
16151619

16161620
Set the option on the router deployment configuration:
16171621

1618-
====
16191622
----
16201623
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=1
16211624
----
1622-
====
16231625

16241626
If you used a non-default name for the router, you must change *_dc/router_*
16251627
accordingly.
@@ -1682,7 +1684,6 @@ Add *timeout http-request* to the default HAProxy router image to
16821684
protect the deployment against distributed denial-of-service (DDoS) attacks (for
16831685
example, slowloris):
16841686

1685-
====
16861687
----
16871688
# and the haproxy stats socket is available at /var/run/haproxy.stats
16881689
global
@@ -1699,7 +1700,6 @@ defaults
16991700
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
17001701
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
17011702
*an error.
1702-
====
17031703

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

0 commit comments

Comments
 (0)