Open pvyaka01 opened 4 years ago
Logs can be sent directly to syslog. No, you don't need consul-template.
If you are interested, there is a presentation done a few months ago about features and architecture of project that has been put online recently: https://www.haproxy.com/user-spotlight-series/building-a-service-mesh-at-criteo-with-consul-and-haproxy/
Yes i saw that project and thank you. I'm using Consul's dashboard and counting example - no docker or k8s. Here's what i noticed:
./haproxy-consul-connect -dataplane /opt/haproxy/bin/dataplaneapi -haproxy /opt/haproxy/bin/haproxy -sidecar-for counting-1 -stats-addr 0.0.0.0:1936 -stats-service-register INFO[0000] consul: watching service counting-1 INFO[0000] consul: watching service counting-1-sidecar-proxy INFO[0000] consul: CA certs changed, active root id: 98:c3:ff:ca:a7:1a:f2:a5:ed:0b:04:3a:80:2c:62:a8:ec:35:3c:64 INFO[0000] consul: CA certs ready INFO[0000] consul: leaf cert for service counting changed, serial: 0e:16:b2, valid before: 2020-05-07 16:33:55 +0000 UTC, valid after: 2020-05-04 16:33:55 +0000 UTC INFO[0000] consul: leaf cert for counting ready INFO[0000] received consul config update INFO[0000] handling new configuration INFO[0000] haproxy: 126/020054 (17625) : New worker #1 (17630) forked ERRO[0000] haproxy: time="2020-05-06T02:00:54Z" level=info msg="HAProxy Data Plane API v2.0.0 448d36e" ERRO[0000] haproxy: time="2020-05-06T02:00:54Z" level=info msg="Build from: git@github.com:haproxytech/dataplaneapi.git" ERRO[0000] haproxy: time="2020-05-06T02:00:54Z" level=info msg="Build date: 2020-04-27T15:28:42Z" INFO[0000] Starting stats server at 0.0.0.0:1936 INFO[0000] state applied WARN[0001] haproxy: 126/020055 (17625) : Reexecuting Master process INFO[0001] haproxy: 126/020055 (17625) : New worker #1 (17639) forked WARN[0001] haproxy: 126/020055 (17630) : Stopping frontend GLOBAL in 0 ms. WARN[0001] haproxy: 126/020055 (17630) : Proxy GLOBAL stopped (FE: 1 conns, BE: 1 conns). WARN[0002] haproxy: 126/020056 (17625) : Former worker #1 (17630) exited with code 0 (Exit)
and /var/log/messages do not show any http stats either:
May 6 02:02:54
I can hit the service and see prometheus style metrics with port
HAProxy version: 2.0.9 (can't use latest due to other reasons)
And ./dataplaneapi --version HAProxy Data Plane API v2.0.0 448d36e
Build from: git@github.com:haproxytech/dataplaneapi.git Build date: 2020-04-27T15:28:42Z
Thanks for your help!
In theory, logs from HAProxy are sent to the same log channel as logs from app and prefixed with haproxy
. We can see some logs from HAProxy in the output you provided:
WARN[0001] haproxy: 126/020055 (17625) : Reexecuting Master process
You can tune the log level with the flag log-level
(INFO) by default and all logs from HAProxy should be displayed (the binding with log level is here: https://github.com/haproxytech/haproxy-consul-connect/blob/master/haproxy/halog/log.go#L55 )
What are the logs you are expecting ?
Sorry perhaps i'm not clear. I'm referring to httplog and tcplog directives. We rely on these quite heavily. We've more than 100 instances of haproxy across multiple environments.
When HAProxy is run as a Layer 7 proxy via mode http, you should add the option httplog directive. It ensures that HTTP requests and responses are analyzed in depth and that no RFC-compliant content will go uncaptured. This is the mode that really highlights the diagnostic value of HAProxy. The HTTP log format provides the same level of information as the TCP format, but with additional data specific to the HTTP protocol. If you were to re-create this format using log-format, it would look like this:
This is from haproxy docs. https://www.haproxy.com/blog/introduction-to-haproxy-logging/
Also, stats page results in "404" http://
Thanks for the help!
Log level trace
will relay haproxy httplog to haproxy-consul-connect stderr. However please note this has a performance cost on high RPS workloads.
Thanks will try that. HAProxy itself doesn't need tracing or even debug to generate httplog. I know this is different. Appreciate the help
Command i used: ./haproxy-consul-connect -dataplane /opt/haproxy/bin/dataplaneapi -haproxy /opt/haproxy/bin/haproxy -sidecar-for counting-1 -stats-addr 0.0.0.0:1936 -stats-service-register -log-level trace
Log level trace does not work at all. Debug works but no http response/request logs like i mentioned before. When i use "-log-level trace" I see below messages:
DEBU[0015] sending dataplane req: POST /v2/services/haproxy/configuration/log_targets?parent_type=frontend&parent_name=front_downstream&transaction_id=16030995-6187-4b7d-be16-a16d4a987dde
ERRO[0015] error calling POST /v2/services/haproxy/configuration/log_targets?parent_type=frontend&parent_name=front_downstream&transaction_id=16030995-6187-4b7d-be16-a16d4a987dde: response was 422: "{"code":602,"message":"index in body is required"}"
DEBU[0016] sending dataplane req: GET /v2/services/haproxy/stats/native
DEBU[0017] sending dataplane req: GET /v2/services/haproxy/stats/native
DEBU[0018] sending dataplane req: GET /v2/services/haproxy/stats/native
INFO[0018] handling new configuration
DEBU[0018] applying new state: {Frontends:[{Frontend:{Clflog:false ClientTimeout:0x122de80 Clitcpka: Contstats: DefaultBackend:back_downstream Dontlognull: Forwardfor:
Thanks
How do i get haproxy stats and logs? Do we need to use consul-template for those?