Skip to content

Commit

Permalink
Add documentation for systemd per-service parsing configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
seveas committed Nov 8, 2024
1 parent ccb54db commit cc4ea7b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pipeline/inputs/systemd.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,24 @@ pipeline:
```
{% endtab %}
{% endtabs %}
### Parsing the MESSAGE field
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:

```yaml
[Unit]
Description=my-service
After=network.target
[Service]
WorkingDirectory=/var/lib/my-service
ExecStart=/usr/sbin/my-service
Restart=always
LogExtraFields=FLUENT_BIT_PARSER=json
[Install]
WantedBy=multi-user.target
```

`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 comments on commit cc4ea7b

Please sign in to comment.