Skip to content

log data in JSON format #21915

Answered by pront
soulg24 asked this question in Q&A
Nov 29, 2024 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

Here is a sample config:

sources:
  source0:
    type: file
    include:
      - "/path/to/log.json"

transforms:
  transform0:
    type: remap
    inputs:
      - source0
    source: |
      .message = parse_json!(string!(.message))

sinks:
  console:
    type: console
    inputs: ["transform0"]
    encoding:
      codec: json
      json:
        pretty: true

The magic happens at .message = parse_json!(string!(.message)) it basically takes the bytes from file (line by line) and constructs an object map. And finally it overwrites the .message with the result.

You try this on the VRL playground. See example.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@soulg24
Comment options

Comment options

You must be logged in to vote
4 replies
@soulg24
Comment options

@jszwedko
Comment options

@pront
Comment options

pront Dec 4, 2024
Maintainer

Answer selected by pront
@soulg24
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
source: file Anything `file` source related domain: transforms Anything related to Vector's transform components
3 participants