Caution
Grafana Agent has reached End-of-Life (EOL) on November 1, 2025. Agent is no longer receiving vendor support and will no longer receive security or bug fixes. Current users of Agent Static mode, Agent Flow mode, and Agent Operator should proceed with migrating to Grafana Alloy. If you have already migrated to Alloy, no further action is required. Read more about why we recommend migrating to Grafana Alloy.
loki.source.journal
loki.source.journal reads from the systemd journal and forwards them to other
loki.* components.
Multiple loki.source.journal components can be specified by giving them
different labels.
Usage
loki.source.journal "LABEL" {
forward_to = RECEIVER_LIST
}Arguments
The component starts a new journal reader and fans out
log entries to the list of receivers passed in forward_to.
loki.source.journal supports the following arguments:
NOTE: A
joblabel is added with the full name of the componentloki.source.journal.LABEL.
When the format_as_json argument is true, log messages are passed through as
JSON with all of the original fields from the journal entry. Otherwise, the log
message is taken from the content of the MESSAGE field from the journal
entry.
When the path argument is empty, /var/log/journal and /run/log/journal
will be used for discovering journal entries.
The relabel_rules argument can make use of the rules export value from a
loki.relabel component to apply one or more relabeling rules to log entries
before they’re forwarded to the list of receivers in forward_to.
All messages read from the journal include internal labels following the
pattern of __journal_FIELDNAME and will be dropped before sending to the list
of receivers specified in forward_to. To keep these labels, use the
relabel_rules argument and relabel them to not be prefixed with __.
NOTE: many field names from journald start with an
_, such as_systemd_unit. The final internal label name would be__journal__systemd_unit, with two underscores between__journalandsystemd_unit.
Component health
loki.source.journal is only reported as unhealthy if given an invalid
configuration.
Debug Metrics
agent_loki_source_journal_target_parsing_errors_total(counter): Total number of parsing errors while reading journal messages.agent_loki_source_journal_target_lines_total(counter): Total number of successful journal lines read.
Example
loki.relabel "journal" {
forward_to = []
rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}
}
loki.source.journal "read" {
forward_to = [loki.write.endpoint.receiver]
relabel_rules = loki.relabel.journal.rules
labels = {component = "loki.source.journal"}
}
loki.write "endpoint" {
endpoint {
url ="loki:3100/api/v1/push"
}
}Compatible components
loki.source.journal can accept arguments from the following components:
- Components that export Loki
LogsReceiver
Note
Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.



