Skip to content

Instantly share code, notes, and snippets.

@poundifdef
Created March 18, 2024 04:31
Show Gist options
  • Save poundifdef/293bf2c4cd5aaa734b0b8e25ebf5309e to your computer and use it in GitHub Desktop.
Save poundifdef/293bf2c4cd5aaa734b0b8e25ebf5309e to your computer and use it in GitHub Desktop.
sources:
scratch_logs:
type: "journald"
include_units: ["scratchworker.service", "scratchdb.service"]
init_logs:
type: "journald"
include_units: ["init.scope"]
transforms:
scratch_transformed:
type: "remap"
inputs: ["scratch_logs"]
source: |
log, err = parse_json(.message)
# Check if the JSON parsing was successful
if is_object(log) {
# JSON is valid and parsed successfully, so assign it to 'log'
.log = log
} else {
# JSON is invalid, so assign the original string to 'log'
.log = .message
}
del(.message)
sinks:
scratch_motherduck:
type: "http"
method: "post"
uri: "https://scratch-v2.fly.dev/data?table=logs&api_key=x"
encoding:
codec: "json"
inputs: ["scratch_transformed", "init_logs"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment