Page MenuHomePhabricator

Append requestctl rule name to X-Analytics header in HAProxy
Closed, ResolvedPublic

Description

Currently logic responsible for appending the requestctl rule name to X-Analytics header is handled by Varnish. This means that requests that are filtered by HAProxy and not forwarded to Varnish are not visible from usual analytics tools.

A solution could be to append the requestctl rule name to X-Analytics directly in HAProxy if not set in the response already (by Varnish).

Pay also attention that the X-Analytics header is deleted as usual before response is sent to the client.

Event Timeline

Change #1164170 had a related patch set uploaded (by Fabfur; author: Fabfur):

[operations/puppet@production] cache,haproxy: set requestctl in x-analytics if not set by varnish

https://gerrit.wikimedia.org/r/1164170

Change #1164170 merged by Fabfur:

[operations/puppet@production] cache,haproxy: set requestctl in x-analytics if not set by varnish

https://gerrit.wikimedia.org/r/1164170

Mentioned in SAL (#wikimedia-operations) [2025-06-26T15:12:47Z] <fabfur> temporary disable puppet on cp7001 (T397917)

Change #1164253 had a related patch set uploaded (by Fabfur; author: Fabfur):

[operations/puppet@production] hiera: set requestctl in x-analytics if not set by varnish (cp7006)

https://gerrit.wikimedia.org/r/1164253

Change #1164253 merged by Fabfur:

[operations/puppet@production] hiera: set requestctl in x-analytics if not set by varnish (cp7006)

https://gerrit.wikimedia.org/r/1164253

Mentioned in SAL (#wikimedia-operations) [2025-06-26T16:30:16Z] <fabfur> depool cp7006 for a quick test (T397917)

Change #1164275 had a related patch set uploaded (by Fabfur; author: Fabfur):

[operations/puppet@production] cache,haproxy: use http-after-response capture for x-analytics

https://gerrit.wikimedia.org/r/1164275

Mentioned in SAL (#wikimedia-operations) [2025-06-27T07:26:19Z] <fabfur> depool cp7007 for testing (T397917)

Mentioned in SAL (#wikimedia-operations) [2025-06-27T14:57:16Z] <fabfur> configuration on cp7007 reverted and host repooled (T397917)

Change #1164275 merged by Vgutierrez:

[operations/puppet@production] cache,haproxy: refactor haproxy captures to fix x-analytics logging

https://gerrit.wikimedia.org/r/1164275

Change #1164952 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] Revert "cache,haproxy: refactor haproxy captures to fix x-analytics logging"

https://gerrit.wikimedia.org/r/1164952

Change #1164952 merged by Vgutierrez:

[operations/puppet@production] Revert "cache,haproxy: refactor haproxy captures to fix x-analytics logging"

https://gerrit.wikimedia.org/r/1164952

Change #1166167 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] cache,haproxy: Remove http response captures

https://gerrit.wikimedia.org/r/1166167

oblivian opened https://gitlab.wikimedia.org/repos/sre/hiddenparma/-/merge_requests/67

haproxy: stop setting x-requestctl header, use txn var instead

oblivian merged https://gitlab.wikimedia.org/repos/sre/hiddenparma/-/merge_requests/67

haproxy: stop setting x-requestctl header, use txn var instead

Change #1166167 merged by Vgutierrez:

[operations/puppet@production] cache,haproxy: Remove http response captures

https://gerrit.wikimedia.org/r/1166167

Mentioned in SAL (#wikimedia-operations) [2025-07-07T07:25:42Z] <vgutierrez> depooling cp7006 to test Ia82b93 - T397917

Mentioned in SAL (#wikimedia-operations) [2025-07-07T07:53:23Z] <vgutierrez> repooling cp7006 with Ia82b93 applied - T397917

Change #1166775 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] cache::haproxy: Fix requestctl= sanitization

https://gerrit.wikimedia.org/r/1166775

Change #1166775 merged by Vgutierrez:

[operations/puppet@production] cache::haproxy: Fix requestctl= sanitization

https://gerrit.wikimedia.org/r/1166775

Change #1167200 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] Revert "cache,haproxy: Remove http response captures"

https://gerrit.wikimedia.org/r/1167200

Change #1167203 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] cache::haproxy: Replace res.hdr() with res.fhdr()

https://gerrit.wikimedia.org/r/1167203

Change #1167203 merged by Vgutierrez:

[operations/puppet@production] cache::haproxy: Replace hdr() with fhdr()

https://gerrit.wikimedia.org/r/1167203

Change #1167200 abandoned by Vgutierrez:

[operations/puppet@production] Revert "cache,haproxy: Remove http response captures"

Reason:

not needed anymore, issue fixed :)

https://gerrit.wikimedia.org/r/1167200

Vgutierrez claimed this task.

During the deployment of https://gerrit.wikimedia.org/r/c/operations/puppet/+/1166167, a bug was introduced in the logging logic due to the use of req.hdr() and res.hdr() instead of req.fhdr() and res.fhdr(). The hdr() fetches treat commas as delimiters and only return the last value, while fhdr() correctly returns the full header value as-is.

As a result, from the time the patch was merged (2025-07-07 07:24 UTC) until it was fixed in https://gerrit.wikimedia.org/r/c/operations/puppet/+/1167203 (2025-07-08 12:03 UTC), requests were sent to the analytics pipeline with truncated header values in some fields:

  • x-cache: Instead of a full value like cp6016 miss, cp6013 hit/757, only the last segment (cp6013 hit/757) was logged.
  • x-analytics: For requests matching multiple Requestctl rules, instead of logging a value like https=1,client_port=12345,requestctl=rule1,rule2, only the last item (rule2) was logged.

This may have affected downstream analytics relying on those fields for that ~29-hour window.