Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
message-call-service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邵兴业
message-call-service
Commits
030e2adb
Commit
030e2adb
authored
Aug 04, 2021
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: filebeat 日志打印
parent
01310dcc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
filebeat.yml
+6
-6
utils/logger.js
+7
-3
No files found.
filebeat.yml
View file @
030e2adb
...
@@ -9,6 +9,10 @@ filebeat.inputs:
...
@@ -9,6 +9,10 @@ filebeat.inputs:
paths
:
paths
:
-
/Users/shaoxingye/Documents/WORK/ownerproject/message-call-service/logs/*.log
-
/Users/shaoxingye/Documents/WORK/ownerproject/message-call-service/logs/*.log
json.keys_under_root
:
true
json.overwrite_keys
:
true
# ============================== Filebeat modules ==============================
# ============================== Filebeat modules ==============================
...
@@ -40,12 +44,8 @@ setup.kibana:
...
@@ -40,12 +44,8 @@ setup.kibana:
# ================================= Processors =================================
# ================================= Processors =================================
processors
:
processors
:
-
decode_json_fields
:
-
drop_fields
:
fields
:
[
'
message'
]
#要进行解析的字段
fields
:
[
"
ecs"
,
"
input"
,
"
agent"
]
target
:
"
"
#json内容解析到指定的字段,如果为空(“”),则解析到顶级结构下
overwrite_keys
:
false
#如果解析出的json结构中某个字段在原始的event(在filebeat中传输的一条数据为一个event)中也存在,是否覆盖event中该字段的值,默认值:false
process_array
:
false
#数组是否解码,默认值:false
max_depth
:
1
#解码深度,默认值:1
...
...
utils/logger.js
View file @
030e2adb
...
@@ -2,8 +2,11 @@ import { createLogger, format, transports } from 'winston';
...
@@ -2,8 +2,11 @@ import { createLogger, format, transports } from 'winston';
import
'winston-daily-rotate-file'
;
import
'winston-daily-rotate-file'
;
import
{
getNamespace
}
from
'cls-hooked'
;
import
{
getNamespace
}
from
'cls-hooked'
;
import
os
from
'os'
import
os
from
'os'
import
moment
from
'moment'
;
import
path
from
"path"
const
myFormat
=
format
.
printf
(({
level
,
message
,
timestamp
,
requestId
})
=>
{
const
myFormat
=
format
.
printf
(({
level
,
message
,
timestamp
,
requestId
})
=>
{
return
`[
${
timestamp
}
] [
${
level
}
]
${
requestId
?
(
"["
+
requestId
+
"] :"
)
:
''
}
${
message
}
`
;
return
`[
${
moment
(
timestamp
).
format
(
"YYYY-MM-DD hh:mm:ss.SSS"
)
}
] [
${
level
}
]
${
requestId
?
(
"["
+
requestId
+
"] :"
)
:
''
}
${
message
}
`
;
});
});
const
requestId
=
format
((
info
)
=>
{
const
requestId
=
format
((
info
)
=>
{
...
@@ -13,11 +16,12 @@ const requestId = format((info) => {
...
@@ -13,11 +16,12 @@ const requestId = format((info) => {
if
(
!
requestId
&&
Object
.
prototype
.
toString
.
call
(
message
)
===
"[object Object]"
&&
message
.
requestId
)
{
if
(
!
requestId
&&
Object
.
prototype
.
toString
.
call
(
message
)
===
"[object Object]"
&&
message
.
requestId
)
{
requestId
=
message
.
requestId
requestId
=
message
.
requestId
}
}
i
nfo
.
requestId
=
requestId
||
'-'
i
f
(
Object
.
prototype
.
toString
.
call
(
message
)
===
"[object Object]"
)
{
info
.
message
=
JSON
.
stringify
(
message
)
info
.
message
=
JSON
.
stringify
(
message
)
}
info
.
requestId
=
requestId
||
'-'
return
info
return
info
})
})
import
path
from
"path"
const
logger
=
createLogger
({
const
logger
=
createLogger
({
level
:
'info'
,
level
:
'info'
,
...
...
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