Skip to content

Instantly share code, notes, and snippets.

@leebenson
Last active December 10, 2024 10:29
Show Gist options
  • Save leebenson/b404ec89c0d4dc6f532db868d8c77514 to your computer and use it in GitHub Desktop.
Save leebenson/b404ec89c0d4dc6f532db868d8c77514 to your computer and use it in GitHub Desktop.
Example Vector config to parse an XML file
[sources.stdin]
type = "stdin"
[transforms.parse_xml]
type = "remap"
inputs = ["stdin"]
source = '''
. = parse_xml!(.message)
.root.new_field = "example_value"
'''
[sinks.console]
type = "console"
inputs = ["parse_xml"]
encoding.codec = "json"
@leebenson
Copy link
Author

leebenson commented Dec 10, 2024

Run:

echo '<root><name>John</name><age>30</age></root>' | ./vector --config vector.toml

You should see in the console (among other things):

{"root":{"age":30,"name":"John Doe","new_field":"example_value"}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment