/etc/google-cloud-ops-agent/config.yaml
logging:
receivers:
app:
type: files
include_paths: [/www/app-*.log]
processors:
monolog:
type: parse_regex
field: message
regex: "^\[(?<time>[^\]]+)\]\s+(?<environment>\w+)\.(?<severity>\w+):\s+(?<msg>.*?)(?<context>{.*})?\s*$"
context:
type: parse_json
field: context
service:
pipelines:
default_pipeline:
receivers: [app]
processors: [monolog,context]
I am trying to configure the pipeline
so that:
- first, cut out the appropriate fragments in flat text
- then format one of those fragments as JSON.
However, it doesn't work. The resulting log only contains the JSON from this chunk, it drops all other data. What am I doing wrong? How to solve it? Fluentbit documentation does not help and Google documentation is minimum information.
I have VMs running docker compose images on Google Cloud. The containers spit out logs at
/var/log/syslog
in the following format (and thats the way they are sent to Logs Explorer (formely Stack Driver):Then, I went out to build a regex that works for structuring that log entry into json format. I tested it on https://rubular.com and it works:
How it works on the config?
First, I use a processor of type
parse_regex
to process and structure my flat log entry in a structured json format.Then, I use another processor of type
parse_json
to collect that structured json and inject it into thejsonPayload
object of the StackDriver log entry.This is the final working configuration: