-
Notifications
You must be signed in to change notification settings - Fork 77
Closed as not planned
Labels
Description
Describe the bug
Apparently parse_json
processor doesn't work when used with tcp
receiver. I need to parse timestamp for a log. If I use the same parse_json
configuration with files
receiver with exactly the same log source everything works as expected.
To Reproduce
Steps to reproduce the behavior:
- Start a GCE VM with image 'rocky-linux-9-v20240515'
- Install Ops Agent version 'google-cloud-ops-agent-2.55.0-1.el9.x86_64.rpm'
- Customize the agent with the following configuration' and restart the agent
logging:
receivers:
test_log:
type: tcp
format: json
processors:
parse_json:
type: parse_json
time_key: timestamp
time_format: "%Y-%m-%dT%H:%M:%S.%LZ"
service:
pipelines:
default_pipeline:
processors: [parse_json]
receivers: [test_log]
- Configure any of the Log4J sources with JSON logging. You can use GcpLayout template provided by the Log4J project.
rootLogger.level = INFO
rootLogger.appenderRef.json_log.ref = json_log
appender.json_log.type = Socket
appender.json_log.name = json_log
appender.json_log.host = localhost
appender.json_log.port = 5170
appender.json_log.layout.type = JsonTemplateLayout
appender.json_log.layout.eventTemplateUri = classpath:GcpLayout.json
-
Now change Google Ops Agent configuration to use
files
receiver:
logging:
receivers:
test_log:
type: files
include_paths:
- /var/log/json/test.log
processors:
parse_json:
type: parse_json
time_key: timestamp
time_format: "%Y-%m-%dT%H:%M:%S.%LZ"
service:
pipelines:
default_pipeline:
processors: [parse_json]
receivers: [test_log]
- Set the source to log to the file, for example:
rootLogger.level = INFO
rootLogger.appenderRef.json_log.ref = json_log
appender.json_log.type = RollingFile
appender.json_log.name = json_log
appender.json_log.fileName = /var/log/json/test.log
appender.json_log.filePattern = /var/log/json/test.log.%i
appender.json_log.strategy.type = DefaultRolloverStrategy
appender.json_log.strategy.max = 1
appender.json_log.layout.type = JsonTemplateLayout
appender.json_log.layout.eventTemplateUri = classpath:GcpLayout.json
appender.json_log.policies.type = Policies
appender.json_log.policies.cron.type = CronTriggeringPolicy
appender.json_log.policies.cron.schedule = 0 0 0 * * ?
appender.json_log.policies.cron.evaluateOnStartup = true
Expected behavior
parse_json
processor should be able to parse timestamps when logs is received via tcp
receiver.
Environment (please complete the following information):
- VM distro / OS: Rocky Linux 9.5
- Ops Agent version 2.55