Skip to content

Commit 6c0359b

Browse files
committed
Add nested field to structured log formatting example; Replace curly quotes with straight quotes.
1 parent 7d56440 commit 6c0359b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/src/user-guide/format-struct-logs-syntax.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,25 @@ Consider the following log event:
6969
"@timestamp": 1427153388942,
7070
"level": "INFO",
7171
"thread": 0,
72-
"latency_secs": 56.4,
72+
"latency": {
73+
"msecs": 56400,
74+
"secs": 56.4,
75+
},
7376
"an.odd.key{name}": "org.apache.hadoop.metrics2.impl.MetricsConfig: loaded properties from hadoop-metrics2.properties"
7477
}
7578
```
7679

7780
We can format this using the following YScope format string:
7881

7982
```
80-
{@timestamp:timestamp:YYYY-MM-DD HH\:MM\:ss.SSS} {level} \{{thread}\} latency={latency_secs:round} {an\.odd\.key\{name\}}
83+
{@timestamp:timestamp:YYYY-MM-DD HH\:MM\:ss.SSS} {level} \{{thread}\} latency={latency.secs:round} {an\.odd\.key\{name\}}
8184
```
8285

8386
* In the first placeholder, we have the field name `@timestamp`, a formatter called `timestamp`, and
84-
the formatters options which are a date format string.
87+
the formatter's options which are a date format string.
8588
* The second and third placeholders simply stringify the values of the given fields.
86-
* The fourth placeholder uses the `round` formatter to round the fields value; this placeholder
87-
doesnt specify any formatter options, so the defaults will be used.
89+
* The fourth placeholder uses the `round` formatter to round a nested field's value; this
90+
placeholder doesn't specify any formatter options, so the defaults will be used.
8891
* The fifth placeholder is for a field whose name contains characters that require escaping.
8992

9093
The formatted string will be:

0 commit comments

Comments
 (0)