Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
9a25cfc8
Commit
9a25cfc8
authored
Oct 29, 2018
by
Andrew Newdigate
Committed by
Sean McGivern
Oct 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix open-ended params for api_json.log
parent
fb8e9729
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
changelogs/unreleased/53155-structured-logs-params-array.yml
changelogs/unreleased/53155-structured-logs-params-array.yml
+5
-0
doc/administration/logs.md
doc/administration/logs.md
+1
-1
lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
...gitlab/grape_logging/formatters/lograge_with_timestamp.rb
+9
-1
No files found.
changelogs/unreleased/53155-structured-logs-params-array.yml
0 → 100644
View file @
9a25cfc8
---
title
:
Use key-value pair arrays for API query parameter logging instead of hashes
merge_request
:
22623
author
:
type
:
other
doc/administration/logs.md
View file @
9a25cfc8
...
...
@@ -84,7 +84,7 @@ Introduced in GitLab 10.0, this file lives in
It helps you see requests made directly to the API. For example:
```
json
{
"time"
:
"201
7-10-10T12:30:11.579Z"
,
"severity"
:
"INFO"
,
"duration"
:
16.84
,
"db"
:
1.57
,
"view"
:
15.27
,
"status"
:
200
,
"method"
:
"POST"
,
"path"
:
"/api/v4/internal/allowed"
,
"params"
:{
"action"
:
"git-upload-pack"
,
"changes"
:
"_any"
,
"gl_repository"
:
null
,
"project"
:
"root/foobar.git"
,
"protocol"
:
"ssh"
,
"env"
:
"{}"
,
"key_id"
:
"[FILTERED]"
,
"secret_token"
:
"[FILTERED]"
},
"host"
:
"127.0.0.1"
,
"ip"
:
"127.0.0.1"
,
"ua"
:
"Ruby"
}
{
"time"
:
"201
8-10-29T12:49:42.123Z"
,
"severity"
:
"INFO"
,
"duration"
:
709.08
,
"db"
:
14.59
,
"view"
:
694.49
,
"status"
:
200
,
"method"
:
"GET"
,
"path"
:
"/api/v4/projects"
,
"params"
:[{
"key"
:
"action"
,
"value"
:
"git-upload-pack"
},{
"key"
:
"changes"
,
"value"
:
"_any"
},{
"key"
:
"key_id"
,
"value"
:
"secret"
},{
"key"
:
"secret_token"
,
"value"
:
"[FILTERED]"
}],
"host"
:
"localhost"
,
"ip"
:
"::1"
,
"ua"
:
"Ruby"
,
"route"
:
"/api/:version/projects"
,
"user_id"
:
1
,
"username"
:
"root"
,
"queue_duration"
:
100.31
,
"gitaly_calls"
:
30
}
```
This entry above shows an access to an internal endpoint to check whether an
...
...
lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
View file @
9a25cfc8
...
...
@@ -6,7 +6,7 @@ module Gitlab
def
call
(
severity
,
datetime
,
_
,
data
)
time
=
data
.
delete
:time
data
[
:params
]
=
utf8_encode_values
(
data
[
:params
])
if
data
.
has_key?
(
:params
)
data
[
:params
]
=
process_params
(
data
)
attributes
=
{
time:
datetime
.
utc
.
iso8601
(
3
),
...
...
@@ -20,6 +20,14 @@ module Gitlab
private
def
process_params
(
data
)
return
[]
unless
data
.
has_key?
(
:params
)
data
[
:params
]
.
each_pair
.
map
{
|
k
,
v
|
{
key:
k
,
value:
utf8_encode_values
(
v
)
}
}
end
def
utf8_encode_values
(
data
)
case
data
when
Hash
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment