Skip to content

Commit 82cff2a

Browse files
committed
Clearly Specify Router Metrics file format returned
1 parent 096d087 commit 82cff2a

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

install_config/router/default_haproxy_router.adoc

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

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

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

385-
====
386383
----
387384
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
388385
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
389386
----
390-
====
391-
392387

393388
[[working-with-multiple-routers]]
394389
== Working With Multiple Routers
@@ -431,7 +426,6 @@ $ oc edit dc <deploymentConfigName>
431426
Add the `template.spec.nodeSelector` field with a key and value
432427
corresponding to the label:
433428
+
434-
====
435429
----
436430
...
437431
template:
@@ -446,7 +440,6 @@ corresponding to the label:
446440
----
447441
<1> The key and value are `router` and `first`, respectively,
448442
corresponding to the `router=first` label.
449-
====
450443

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

493-
494486
*Router Sharding Examples*
495487

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

656-
====
657648
[source,bash]
658649
----
659650
#!/bin/bash
@@ -673,7 +664,6 @@ oc scale $dc --replicas=3 //<5>
673664
The selection expression is the value of
674665
the `ROUTE_LABELS` environment variable.
675666
<5> Scale it up.
676-
====
677667

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

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

715-
====
716705
[source,bash]
717706
----
718707
#!/bin/bash
@@ -735,7 +724,6 @@ oc scale $dc --replicas=3 //<5>
735724
non-`ID` arguments to `modshard` must include the
736725
environment variable name as well as its value.
737726
<5> Scale it back up.
738-
====
739727

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

878-
====
879866
----
880867
routingConfig:
881868
subdomain: v3.openshift.test
882869
----
883-
====
884870

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

895-
====
896881
----
897882
no-route-hostname-mynamespace.v3.openshift.test
898883
----
899-
====
900884

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

912-
====
913896
----
914897
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
915898
----
916-
====
917899

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

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

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

949-
====
950929
----
951930
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
952931
----
953-
====
954932

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

957-
====
958935
----
959936
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
960937
----
961-
====
962938

963939
[NOTE]
964940
====
@@ -1109,7 +1085,6 @@ DNS lookup:
11091085
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
11101086
----
11111087

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

@@ -1443,18 +1418,14 @@ stack, use the `--host-network=false` option when creating the router. For
14431418
example:
14441419

14451420
ifdef::openshift-enterprise[]
1446-
====
14471421
----
14481422
$ oc adm router --service-account=router --host-network=false
14491423
----
1450-
====
14511424
endif::[]
14521425
ifdef::openshift-origin[]
1453-
====
14541426
----
14551427
$ oc adm router --service-account=router --host-network=false
14561428
----
1457-
====
14581429
endif::[]
14591430

14601431
Internally, this means the router container must publish the 80 and 443
@@ -1479,7 +1450,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
14791450
add routes across the namespaces.
14801451
====
14811452

1482-
14831453
[[exposing-the-router-metrics]]
14841454
== Exposing Router Metrics
14851455

@@ -1488,55 +1458,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
14881458
are, by default, exposed or published in
14891459
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
14901460
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1491-
Metrics are also available dirctly from the
1492-
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1461+
Metrics are also available directly from the
1462+
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1463+
or CSV download.
1464+
These metrics include the HAProxy native metrics and some controller metrics.
1465+
1466+
When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
14931467

1494-
When you create a router, as below,
1495-
====
14961468
----
14971469
$ oc adm router --service-account=router
14981470
----
1499-
====
1500-
metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1501-
====
1471+
1472+
* To extract the raw statistics in Prometheus format run the following command:
1473+
+
15021474
----
1503-
$ oc adm router --service-account=router --stats-port=0
1475+
curl <user>:<password>@<router_IP>:<STATS_PORT>
15041476
----
1505-
====
1506-
1507-
To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1508-
for the router dc and delete the following lines:
1509-
1510-
====
1477+
+
1478+
For example:
1479+
+
15111480
----
1512-
- name: ROUTER_LISTEN_ADDR
1513-
value: 0.0.0.0:1936
1514-
- name: ROUTER_METRICS_TYPE
1515-
value: haproxy
1481+
$ curl admin:[email protected]:1936/metrics
15161482
----
1517-
====
1518-
Where 1936 is the STATS_PORT value.
1519-
1520-
You can extract the raw statistics in Prometheus format by using the following.
1521-
1522-
Information needed to access the metrics is found the router service annotations:
1523-
1524-
====
1483+
+
1484+
You can get the information you need to access the metrics from the router service annotations:
1485+
+
15251486
----
1487+
$ oc edit router service <router-service-name>
1488+
1489+
apiVersion: v1
1490+
kind: Service
15261491
metadata:
15271492
annotations:
15281493
prometheus.io/port: "1936"
15291494
prometheus.io/scrape: "true"
15301495
prometheus.openshift.io/password: IImoDqON02
15311496
prometheus.openshift.io/username: admin
15321497
----
1533-
====
1534-
1535-
The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1536-
Use the above username and password to access the metrics. The path is "/metrics".
1537-
1498+
+
1499+
The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1500+
Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1501+
+
15381502
----
1539-
$ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1503+
$ curl <user>:<password>@<router_IP>:<STATS_PORT>
15401504
for example:
15411505
$ curl admin:[email protected]:1936/metrics
15421506
...
@@ -1566,6 +1530,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
15661530
...
15671531
----
15681532

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

15701573
[[preventing-connection-failures-during-restarts]]
15711574
== Preventing Connection Failures During Restarts
@@ -1576,6 +1579,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
15761579
around the problem by installing `iptables` rules to prevent connections during
15771580
the reload window. However, doing so means that the router needs to run with
15781581
elevated privilege so that it can manipulate `iptables` on the host. It also
1582+
15791583
means that connections that happen during the reload are temporarily ignored and
15801584
must retransmit their connection start, lengthening the time it takes to
15811585
connect, but preventing connection failure.
@@ -1608,11 +1612,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
16081612

16091613
Set the option on the router deployment configuration:
16101614

1611-
====
16121615
----
16131616
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=1
16141617
----
1615-
====
16161618

16171619
If you used a non-default name for the router, you must change *_dc/router_*
16181620
accordingly.
@@ -1675,7 +1677,6 @@ Add *timeout http-request* to the default HAProxy router image to
16751677
protect the deployment against distributed denial-of-service (DDoS) attacks (for
16761678
example, slowloris):
16771679

1678-
====
16791680
----
16801681
# and the haproxy stats socket is available at /var/run/haproxy.stats
16811682
global
@@ -1692,7 +1693,6 @@ defaults
16921693
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
16931694
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
16941695
*an error.
1695-
====
16961696

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

0 commit comments

Comments
 (0)