Skip to content

Enable access log for the __health endpoint #1958

@matthieumarrast

Description

@matthieumarrast

Problem

Currently, in the nginx.conf file, the access log is set to off for the /__health endpoint (access_log off;):

# healthcheck endpoint for load-balancer
        location = /__health {
            access_log off;
            set $plugin "#monitoring#";
            content_by_lua_block {
                require("mfserv.health")()
            }
        }

so in the nginx_access.log, the HTTP requests made on this /__health endpoint are not traced.

It is well indicated (as a comment) that is endpoint is made "for load-balancer". But if we face difficulties while configuring our load-balancer it should be great to make possible to activate the access_log for this endpoint. Also we can "trace" the HTTP request made by the load-balancer.

Solution

Add a config health_access_log (under the existing "health_location") to allow access log for this endpoint

# health_location = /__health
health_access_log=0

Workaround

  • edit file ~/tmp/config_auto/nginx.conf by removing the line access_log off; for the __health endpoint
  • send a sigquit to the openresty process (execute ps -edf | grep openresty to get the pid)
kill -3 <pid>

(the openresty process is restarted by circus taking into account the update of the configuration)
Check the log and you should see the __health requests:

{ "@timestamp": "2024-10-15T10:06:40+00:00", "from": "172.24.1.252", "host": "127.0.0.1", "method": "GET", "uri": "/", "duration": 0.000, "status": 200, "request_length": 7, "reply_length": 1198, "plugin": ""***********", ", "request_id": "9d3dd6677901b15c6246f586a8aeb4d4" }
{ "@timestamp": "2024-10-15T10:06:40+00:00", "from": "172.24.1.251", "host": "127.0.0.1", "method": "GET", "uri": "/__health", "duration": 0.001, "status": 200, "request_length": 15, "reply_length": 3, "plugin": "#monitoring#", "request_id": "729e19fc9625bedde35fc1e1195070b0" }
{ "@timestamp": "2024-10-15T10:06:45+00:00", "from": "172.24.1.250", "host": "127.0.0.1", "method": "GET", "uri": "/__health", "duration": 0.000, "status": 200, "request_length": 15, "reply_length": 3, "plugin": "#monitoring#", "request_id": "68e922d50e4f417c9c4c75db9b2a03e7" }
{ "@timestamp": "2024-10-15T10:06:45+00:00", "from": "172.24.1.252", "host": "127.0.0.1", "method": "GET", "uri": "/", "duration": 0.000, "status": 200, "request_length": 7, "reply_length": 1198, "plugin": "***********", "request_id": "24353cf5703633ed6437d2fcde5a52ca" }
{ "@timestamp": "2024-10-15T10:06:45+00:00", "from": "172.24.1.251", "host": "127.0.0.1", "method": "GET", "uri": "/__health", "duration": 0.000, "status": 200, "request_length": 15, "reply_length": 3, "plugin": "#monitoring#", "request_id": "d66baab5be45beb8cba2398bb0057063" }

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions