Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for systemd per-service parsing configuration #1508

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.