Include route identifier in access logs

In Prometheus we use the route identifier as a label on all http metrics. For example:

gitlab_workhorse_http_requests_total{code="200",route="^/-/(readiness|liveness)$"}

(note the route label here)

When GitLab.com receive alerts for Workhorse, it's easy for the operator for determine if the degradation is on a single route using the metrics.

If it is the case that the degradation is isolated to a single route, they may want to investigate further by reviewing log for the service.

Unfortunately, at present, we don't include this label in our logs, making it difficult to match metrics with logs.

Having the same label as a structured field on the logs would help speed up diagnosis by allowing the operator to match logs with the metrics.

This MR adds this field to the logs:

{"content_type":"text/plain","correlation_id":"KDAPSuUZKx6","duration_ms":2,"host":"localhost:8181","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:56836","remote_ip":"127.0.0.1","route":"^/api/graphql\\z","status":502,"system":"http","time":"2020-10-08T11:31:03+02:00","uri":"/api/graphql","user_agent":"curl/7.71.1","written_bytes":24}

(note the new route label here)

Edited by Andrew Newdigate

Merge request reports

Loading