Skip to content

Commit cc4ea7b

Browse files
committed
Add documentation for systemd per-service parsing configuration
1 parent ccb54db commit cc4ea7b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pipeline/inputs/systemd.md

+21
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,24 @@ pipeline:
7777
```
7878
{% endtab %}
7979
{% endtabs %}
80+
81+
### Parsing the MESSAGE field
82+
83+
By default, the _Systemd_ plugin logs all fields in the journal verbatim. If you want to parse the `MESSAGE` field, you can configure your service to specify a parser. For example, to parse the `MESSAGE` field as JSON, you can use something like the following systemd configuration:
84+
85+
```yaml
86+
[Unit]
87+
Description=my-service
88+
After=network.target
89+
90+
[Service]
91+
WorkingDirectory=/var/lib/my-service
92+
ExecStart=/usr/sbin/my-service
93+
Restart=always
94+
LogExtraFields=FLUENT_BIT_PARSER=json
95+
96+
[Install]
97+
WantedBy=multi-user.target
98+
```
99+
100+
`LogExtraFields` will make the specified fields appear in the log output. The `Systemd` plugin will look for a `FLUENT_BIT_PARSER` field and use it to parse the `MESSAGE` field. If the parser is not found or parsing fails, the unparsed message is added to the log entry as if no parser was specified.

0 commit comments

Comments
 (0)