Loading
Add gl_key_type and gl_key_id to audit event logs
What does this MR do?
Adds gl_key_type and gl_key_id to the log context when sending git audit events.
Why?
When debugging deploy key audit event failures in production (Kibana/Elasticsearch), the logs previously only
showed:
- gl_repository
- command
- username
This made it difficult to identify which key was involved when errors occurred. With this change, the key type
(e.g., deploy_key) and key ID are now included in the logs.
Example log output
Before:
{
"msg": "failed to audit git event: The project you were looking for could not be found...",
"gl_repository": "project-19",
"command": "git-upload-pack",
"username": "ghost"
} After:
{
"msg": "failed to audit git event: The project you were looking for could not be found...",
"gl_repository": "project-19",
"command": "git-upload-pack",
"username": "ghost",
"gl_key_type": "deploy_key",
"gl_key_id": 14
} Rollout Plan
This MR is part of a coordinated git audit event error fix across gitlab-shell and GitLab Rails.
Step 1: gitlab-shell
- Merge !1411 (merged) (pass
key_idto audit endpoint) - Merge this MR
- Release new version (e.g., v14.48.0)
Step 2: GitLab Rails
After gitlab-shell release, a follow-up Rails MR will:
- Bump
GITLAB_SHELL_VERSIONto the new version - Remove deploy key guard in
Gitlab::GitAuditEvent#enabled? - Add
key_idparam documentation to shellhorse endpoint
Related issues
MR acceptance checklist
- Tests pass
- Changelog entry added
Edited by Emma Park