<br>
=Using HAproxy metrika végpont használataMetric Endpoint=A HAproxyhas a built-nak van beépített metrika végpontjain metric endpoint, ahol alapértelmezetten which by default provides Prometheus szabványú metrikákat szolgáltat -standard metrics (tud még you can still CSV-tis). Az így nyert metrikák nagy része nem igazán értelmes metrikákMost of the metrics you get are not really meaningful metrics. Két olyan metrikát tudunk innen kinyerniThere are two metrics that can be extracted here, ami mindenképpen figyelendő which are definitely to be observed in prometheus-ban, ezek a hibás és broken down into backscatter and 200-as válaszok számlálói backend-ekre lebontvaresponse counters.
A metrikákat lekérdező végpont The metric query endpoint (metrics) alapból is on by default. This can be van kapcsolva. Ezt ki lehet kapcsolniturned off, de attól még gyűjteni fogja a metrikákat a but HAProxywill still collect metrics from it. A The HAproxy pod két komponensből épül felis made up of two components. Az egyik maga a One is HAproxy a másik a itself and the other is the router-controller ami a that manages the HAproxy konfigurációját kezeliconfiguration. A metrikákat mind a két komponensről Metrics are collected from both components every 5 másodpercenként gyűjti be a metrika kezelőseconds by the metric manager. A metrikák között vannak Metrics include frontend és and backend metrikák is külön szolgáltatásonként összegyűjtvemetrics collected by separate services.
:[[File:ClipCapIt-190808-094455.PNG|600px]]
<br>
==Metrikák lekérdezéseQuery Metrics ==A metrikák lekérdezésére két lehetőség vanThere are two ways to query metrics. # felhasználó név username + jelszó használatapassword: Basic authentikácóval a authentication calls the /metrics végpontot meghívva le lehet kérdezni a metrikákatendpoint to query the metrics. # Defining RBAC szabályok definiálása a megfelelő Rules for the appropriate serviceAccount -hoz: Gépi feldolgozásra For machine processing (Prometheus) lehetőség van rá, hogy it is possible to enable RBAC szabályokkal engedélyezzük egy adott rules for a given service-account-nak hogy lekérdezze a metrikákatto query the metrics.
<br>
===User + jelszó alapú lekérdezés password based query ===
Felhasználó név alapú lekérdezés esetén az alapértelmezett metrika For a user name query, the default metric URL az alábbiis: <prePre>http://<user>:<password>@<router_IP>:<STATS_PORT>/metrics</prePre>
A metrika The user, jelszó és password, and port a metrics are in the service definition for the router-hez tartozó service definíciójában van. Ehhez elsőként meg kell keresni a To do this, you first need to find the router-hez tartozó service-t:
<pre>
# kubectl get svc -n default
router ClusterIP 172.30.130.191 <none> 80/TCP,443/TCP,1936/TCP 4d
</pre>
Láthatjuk, hogy az You can see that it is listening on port '''1936'''-os porton , which is hallgatózik, ez a metrika végpontjának a portjathe port of the endpoint of the metric.
Most nézzünk bele a Now, let's look at the service definíciójába, hogy megkapjuk a definition to get the user és and pass-t is:
<source lang="C++">
# kubectl get svc router -n default -o yaml
Ennek függvényébenDepending on this, a using the node 's IP címét felhasználvaaddress, (minishfit IP) a metrika , the URL az alábbifor the metric is: http://admin:4v9a7ucfMi@192.168.42.64:1936/metrics (ezt böngészőben nem lehet meghívni, mert nem ismerik ezt a formátumotThis browser cannot be called because it is not familiar with this format)
<pre>
# curl admin:4v9a7ucfMi@192.168.42.64:1936/metrics
===ServiceAccount alapú lekérdezésbased query ===Lehetőség van rá, hogy ne csak It is possible to query the HAproxy metrics not only with basic authentication-el kérdezzük le a HAproxy metrikákat, hanem but also with RBAC szabályokkalrules.
Készíteni kell egy olyan You need to create a '''ClusterRole'''-t ami megengedi hogy lekérdezést kezdeményezzünk that allows you to initiate a query at the'''routers/metrics''' végpontonendpoint. Ezt később össze fogjuk rendelni a This will be mapped to serviceAccount running prometheus-t futtató serviceAccount-allater.
<br>
'''cr-prometheus-server-route.yaml'''
Második lépésben készíteni kell egy The second step is to create a '''ClusterRoleBinding'''-ot, ami összerendeli a that binds the serviceAccount belonging to the prometheus-hoz tartozó serviceAccount-ot a fenit with the phenite role-al.
<br>
'''crb-prometheus-server-route.yaml'''
namespace: mynamespace
</source>
Hozzuk létre a két feni objektumotLet's create the two above objects:
<pre>
# kubectl apply -f cr-prometheus-server-route.yaml
<br>
==Prometheus integrációintegration==
Keressük meg router-ekhez tartozó Look for the definition of '''Endpoint''' definíciótfor routers. Ezt fogjuk hozzáadni a This will be added to the prometheus konfigurációhoz, amivel az összes configuration so you can search for all router pod-ot meg tudja majd keresnipods. Olyan We will look for an endpoint-t fogunk keresni, aminek a neve called '''router''' és van and have a port called '''1936-tcp''' nevű portja, amin keresztül le fogjuk kérdezni az alapértelmezett metrika végponton through which we will query the HAproxy metrics via the default metric endpoint (/metrics) keresztül a HAproxy metrikákat.
<pre>
# kubectl get Endpoints router -n default -o yaml
<br>
<br>
A In the Promethues konfigurációba hozzá kell adni egy új configuration, you need to add a new '''target''in which to find the'-et, amiben Endpoint 'named''kubernetes_sd_configs'router ''-al keressük meg azt az Endpoint-ot, aminek a neve and ''with 'router''kubernetes_sd_configs' és van ''. Port of '1936-tcp''' nevű portja.
<pre>
- job_name: 'openshift-router'
</pre>
Frissítsük a Prometheus konfigurációját tartozó Update the '' '''ConfigMap'''-etof your Prometheus configuration.
<pre>
# kubectl apply -f cm-prometheus-server-haproxy.yaml
Nézzük meg a promethues Let's see in the prometheus pod-ban, hogy a konfiguráció újra lett e már töltvethat the configuration has been reloaded:
<pre>
# kubectl describe pod prometheus-server-75c9d576c9-gjlcr -n mynamespace