Backport of 'Log nested counted_by values as strings'

What does this MR do and why?

Backports !270871 (merged) to 19.5.

The Rate_Limit_Block line in auth_json.log has a counted_by field with the values that the blocking rule counts by. The product analytics collector rule counts by the aid query param. Rack parses ?aid[x]=1 to a Hash and ?aid[]=1&aid[]=2 to an Array, so counted_by.aid is a string on some lines, an object on others, and an array on others. Elasticsearch drops a line whose field shape does not match the index mapping, as it did for applies_to before !266584 (merged).

This MR logs each counted_by value with to_s, only in the log line. labkit 5.5.0, the version on 19.5, also builds the counter key with to_s (Evaluator#resolve_char_value), so the logged value is the bucket that LabKit counted. The counters and the rule matching do not change. The other values (ip, requester_type, requester_id, runner_id, path) are already strings on 19.5, so to_s does not change them. With Ruby 3.3, the default on 19.5, ?aid[x]=1 is logged as {"x"=>"1"}.

Why this is a bug fix

!270871 (merged) is ~"type::bug" on master. When the logs go to Elasticsearch, as on GitLab.com, a dropped Rate_Limit_Block line cannot be searched, so the record of the block is lost.

Conflict resolution

None. The cherry-pick of the merge commit 6a7a2309 applied cleanly.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required).
  • Ensure the E2E Omnibus GitLab EE pipeline (triggered by thee2e:test-on-omnibus-ee job) has succeeded. If it has failed (or shows warnings), investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Merge request reports

Loading
Loading