forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapped_json.yaml
More file actions
42 lines (36 loc) · 1.24 KB
/
wrapped_json.yaml
File metadata and controls
42 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# JSON Configuration Example
# ------------------------------------------------------------------------------
# A simple example that parses incoming data as JSON. This example also
# demonstrated wrapped JSON, showing that you can chain VRL expressions
# together to quickly traverse nested objects with simple path notation.
data_dir: "/var/lib/vector"
# Ingest data
# Example: {"message": "{\"parent\": \"{\\\"child\\\": \\\"value2\\\"}\"}"}
# Docs: https://vector.dev/docs/reference/configuration/sources/file
sources:
logs:
type: "file"
include: [ "/var/log/*.log" ]
ignore_older_secs: 86400 # 1 day
# Parse the data as JSON
# Docs: https://vector.dev/docs/reference/configuration/transforms/remap
transforms:
parse_json:
inputs: [ "logs" ]
type: "remap"
drop_on_error: false
source: |
message = del(.message)
. |= object!(parse_json!(string!(message)))
parent = del(.parent)
. |= object!(parse_json!(string!(parent)))
child = del(.child)
. |= object!(parse_json!(string!(child)))
# Print the data to STDOUT for inspection
# Docs: https://vector.dev/docs/reference/configuration/sinks/console
sinks:
out:
inputs: [ "parse_json" ]
type: "console"
encoding:
codec: "json"