Changes

Openshift - HAproxy metrics EN

140 bytes removed, 10:42, 25 January 2020
no edit summary
[[Openshift - HAproxy metrics|Openshift - HAproxy metrics HU]]
:[[File:ClipCapIt-190807-102633.PNG]]
* '''port: 9144''' -> The http port of the /metrics endpoint
<br>
{{warning | do Do not forget to set the value of '''readall''' to 'false' in a live environment as it can significantly degrade performance}}
<br>
<br>
CMD sh -c "nohup /usr/sbin/rsyslogd -i ${PID_DIR}/pid -n &" && ./grok_exporter -config /grok/config.yml
</source>
{{note | It is important to use grok-exporter version 0.2.7 or higher, as functions were introduced in this version}}
<br>
cluster role "cluster-admin" added: "admin"
</Pre>
{{note | If we get this error '''Error from server (NotFound): the server could not find the requested resource''', it probably means that our oc client is older than OpenShift version}}
- system: serviceaccount: default: haproxy-exporter
...
</ Sourcesource>
deploymentconfig.apps.openshift.io/myrouter updated
</pre>
{{note | In minishift, in the router containers the name resolution does not work for Kubernetes service names, because it doesn't use the Kubernetes cluster DNS server but the minishfit VM. Therefore, all you have to do is enter the service's IP address instead of its name. In OpenShift, we have to use the name of the service}}
As a second step, change the HAproxy log level to debug, because it only produces access log in debug level.
deploymentconfig.apps.openshift.io/myrouter updated
</pre>
{{warning | Performance test must be carried out to see how much is the extra load when running the haproxy in debug mode}}
Please open the gork-exporter metrics at http://<pod IP>:9144/metrics. You can open this URL either in the haproxy-exporter pod itself with on localhost or in any other pod using the haporxy-exporter pod's IP address. We have to see the '''haproxy_http_request_duration_seconds_bucket''' histogram among the metrics.
<pre>
# kubectl exec -it test-app-57574c8466-qbtg8 / bin / bash -n mynamespace
$
$ curl http://172.30.213.183:9144/metrics
      static_configs:
      - targets: ['grok-exporter-service.default: 9144']
</ Sourcesource
=== Pod Level Data Collection ===
= OpenShift router + rsyslog =
Starting with OpenShift 3.11, it is possible to define fire up a router that will openShfit automatically launch contain a side car rsyslog container in the router pod and configure HAproxy to send logs to the rsyslog server via an emptyDir volume , which writes them to stdout by default. The configuration of rsyslog is in a configMap.
[[File: ClipCapIt-190810-164907.PNG]]
<br>
You can create a router with syslogserver using the '''--extended-logging''' switch with in the command '''' 'oc adm router'''command.
<pre>
# oc adm router myrouter --extended-logging -n default
<br>
Turn on the debug level loging in HAproxy:
<pre>
# oc set env dc / myrouter ROUTER_LOG_LEVEL = debug -n default
You can see that the '''/ var / lib / rsyslog /''' folder is mounted in both containers. You will create the The rsyslog.sock file will be created here in your HAproxy configuration file.
<br>
<br>
=== router container ===
When we enter the router container, we can see that the configuration has already been lickedmodified:
<pre>
# kubectl exec -it myrouter-2-bps5v / bin / bash -n default -c router
<br>
If you want to reconfigure rsyslog to send logs to eg e.g, logstash then you only need to rewrite the configMap. By default, it rsyslog only writes to stdout what you get.
<pre>
# kubectl get cm rsyslog-config -n default -o yaml