Collecting systemd journal logs into Loki

Grafana Alloy reads the systemd journal with loki.source.journal and ships it to Loki, but only if the alloy user has the right group memberships. This page covers the setup, labelling by unit and the silent failure to check first.

On this page

How Grafana Alloy collects systemd journal logs into Loki

Linux hosts already write their system and service logs to the systemd journal, and most teams want those entries in the same self-hosted Loki cluster as their other logs. Grafana Alloy does this with the loki.source.journal component, which reads the journal on the host and forwards entries to Loki through a writer component. This is the documented Alloy component for the job, so you configure it like any other Alloy pipeline rather than building a custom connector or log shipper.

The whole path stays inside your infrastructure. Alloy runs on the hosts you already manage, reads the local journal, and sends entries to the Loki endpoint in your own network, so no log content leaves your environment on the way. Plan the Alloy install, its service account, and the Loki write endpoint as part of the same change, because the journal collector is only one link in a chain that also depends on authentication and tenant headers at the Loki side.

Before you write the pipeline, decide which hosts will run Alloy and how it will be started and upgraded. Confirm the Alloy version and the host operating system against the Alloy documentation, and confirm the journal path on each host, since journals can be stored persistently or only in volatile memory depending on the distribution's configuration. Also decide which journal fields you need, because the component attaches them to entries and the labels you keep become the basis for querying in Loki.

The most important check is permissions. The user that runs Alloy must be in the adm and systemd-journal groups, and the documentation warns that without them the component starts without error but collects no entries. Verify this on every host, after every package or image change that might create or recreate the service account, and by querying Loki for a known unit's recent entries once the pipeline is running.

What the host and Loki need before journal collection works

Journal collection depends on three layers working together: a Linux host with journald, a Grafana Alloy process that can read the journal, and a Loki push endpoint that accepts the stream. Each layer can fail silently, so confirm them in this order before you write the component configuration.

A reachable self-hosted Loki

Alloy pushes journal entries to Loki's write path, so the host must reach that endpoint over the network. Check that DNS resolves the Loki hostname, that firewalls allow the port your deployment exposes, and that TLS trust is in place if you use HTTPS. Confirm the Loki version you run against the vendor's current documentation rather than assuming a release, because the push path and deployment mode determine the URL you configure.

Loki deployment modes

Grafana Alloy on the host

Alloy runs the loki.source.journal component that reads the journal and the loki.write component that ships entries. Install it as a service on each host you want to cover, and confirm the Alloy version against the current Alloy release notes before you deploy. The service must start under a user account you control, because that account determines which journal entries Alloy can read.

loki.source.journal docs

Hosts running systemd-journald

The component reads the systemd journal, so each target host must run systemd-journald and write persistent or volatile journal storage that you can query. Check the journal with journalctl as the Alloy service user before configuring anything. Containers that do not run systemd, minimal images and some appliances may not provide a journal, and those hosts need a different collection path.

The adm and systemd-journal groups

The alloy user must belong to the adm and systemd-journal groups to read journal entries. Without them, the component starts cleanly, reports no error, and collects nothing, which is the failure most teams hit first. Add the groups with usermod -aG adm,systemd-journal alloy on the host, then restart the Alloy service so the new group membership takes effect.

Groups required
2
Alloy journal reference

Push endpoint network and tenant headers

If Loki runs with auth_enabled set to true, every push must carry an X-Scope-OrgID header naming the tenant, or Loki rejects the request. Configure the tenant ID on the loki.write component and confirm that the tenant exists and has write permission. Put the authenticating reverse proxy that Loki requires in front of the endpoint, and check that Alloy can present whatever credentials that proxy expects.

Loki multi-tenancy docs

Configuring loki.source.journal step by step

This sequence takes a Linux host from a readable systemd journal to journal entries arriving in Loki with a unit label, and it shows where each step can fail silently.

  1. Confirm the journal is readable on the host

    Before touching Alloy, check that the host has a journal you can read and that you can see entries from a known unit. Run journalctl -u ssh -n 5 or another unit that logs on your host, and confirm output appears. Log in as an administrator for this check. If journalctl returns nothing for units you expect, fix the logging setup first, because Alloy can only forward what the journal holds. The step is done when recent entries from a named unit print to your terminal.

  2. Add the alloy user to the journal groups

    Grant the account that runs Alloy read access to the journal by adding it to the adm and systemd-journal groups, for example with sudo usermod -aG adm,systemd-journal alloy. Group membership is applied when a process starts, so the change does not affect a running Alloy service. Confirm the result with id alloy, which should list both groups. This is the step most often skipped: if the permission is missing, loki.source.journal still starts without an error and collects no entries, so do not rely on the service status alone.

  3. Define the loki.source.journal block

    In the Alloy configuration file, usually /etc/alloy/config.alloy, add a loki.source.journal block with a forward_to argument pointing at a receiver. Set labels to a small, fixed set such as job = "systemd-journal" and host, and use a relabel_rules block to map the journal field __journal__systemd_unit to a unit label. Keep unit names as the main label and avoid mapping high-cardinality journal fields such as message text or process IDs into labels. The step is done when the file passes validation with alloy fmt or the equivalent check your install provides.

  4. Connect the source to a loki.write component

    Add a loki.write component with an endpoint block whose url points at your Loki push API, for example the /loki/api/v1/push path on your Loki host. Set the forward_to argument of loki.source.journal to the receiver export of this loki.write component. If your cluster has auth_enabled set to true, add the tenant_id value for the tenant that should own these logs. The step is done when the two components reference each other by name and the file still validates.

  5. Restart Alloy and read its status

    Restart the service with sudo systemctl restart alloy, then check systemctl status alloy and the Alloy log with journalctl -u alloy. Look for the component starting and for errors about the Loki endpoint, authentication or the journal. A component that reports healthy but writes nothing usually points to the group membership from the earlier step, so recheck id alloy if no entries appear in the next step. The step is done when Alloy reports running with no errors for the journal or write components.

  6. Verify the unit label in Grafana

    In Grafana, open Explore, select your Loki data source and run a query such as {job="systemd-journal"} over the last few minutes. Then filter on a unit you generated activity for, for example {job="systemd-journal", unit="ssh.service"}. Entries with the expected unit label confirm the whole path works. If the query returns nothing, check the tenant header, the time range and the group membership before changing the configuration. The step is done when a unit-filtered query returns recent journal lines.

Which journal fields become labels and why unit is the one to keep

The label decision for journal logs comes down to one rule: keep unit as the Loki label and leave almost everything else out of the index. Grafana Alloy's loki.source.journal component reads journal entries with their fields exposed as __journal_ prefixed internal labels, such as __journal__systemd_unit and __journal_priority_keyword. These internal labels are not stored in Loki unless a loki.relabel block copies them into a label you name. The usual pattern is a rule that maps __journal__systemd_unit to unit, so queries can select one service at a time, for example {unit="sshd.service"}. Confirm the exact internal label names against your Alloy version in the component reference, because they are the source of most relabeling mistakes.

Every extra label multiplies the number of streams Loki must index and store, so the fields you add to the label set should be ones that stay few and stable. Fields such as _PID, _HOSTNAME on a single host, or message-level identifiers change constantly or grow with traffic, and making them labels is the fastest way to inflate the index. Priority, syslog identifier and transport are the candidates to weigh against that cost, and you should decide each one deliberately rather than mapping every journal field by default. Fields you still want to filter on can be kept in the log line for text filters, or attached as structured metadata where your Loki version supports it. Check the relevant Loki documentation for how structured metadata behaves in your deployment before you depend on it.

The labelling choice shapes every later query. With unit as a label, a LogQL selector narrows the search before any line filtering happens, which keeps queries on a busy host fast and inexpensive. A field left in the message body can still be found with a line filter, but the search scans more data. Decide the label set before the first host is enrolled, and write it down with the team that will query it, because renaming labels later splits history across old and new series. Test the labels on one host, run the queries your on-call engineers will actually use, and confirm they return the expected units before rolling the configuration across the fleet.

Journal fields mapped to Loki labels and what each one is for

This table maps common journal fields to suggested Loki labels, explains why each one helps, and rates whether it suits a label or belongs in structured metadata or the log line. Confirm the exact field names against the Alloy component reference for your installed version before you write relabel rules. The main takeaway is that unit and priority are usually safe labels, while raw message content and per-process identifiers should stay out of labels.

Journal fieldSuggested Loki labelWhy it is usefulCardinality guidance
_SYSTEMD_UNITunitGroups entries by service, such as sshd or a custom application unit, the most common query starting pointLow cardinality, keep as a label on most hosts
_HOSTNAMEhost or instanceSeparates entries from many machines in one tenant when the sender does not add its own host labelLow to moderate, bounded by fleet size
PRIORITYpriority or levelLets you filter errors and warnings without parsing message textLow cardinality (eight syslog levels), a good label
SYSLOG_IDENTIFIERsyslog_identifierNames the program that wrote the entry when no unit exists, such as cron jobs or scriptsLow to moderate, can grow with many ad hoc tools
_PID or _CMDLINENot recommended as a labelUseful for investigation inside a single entry, but values change on every process startHigh cardinality, keep in the log line or structured metadata
MESSAGENot a labelThe log body itself, searched with line filters in LogQLUnbounded, never use as a label
_TRANSPORT or _COMMOptional, usually omittedAdds detail about how an entry arrived or which binary emitted itLow, but rarely needed for routine queries

Permissions for package-installed Alloy, containers and hardened hosts

A package install of Grafana Alloy normally runs the service under a dedicated alloy user. For loki.source.journal to read entries, that user must be a member of the adm and systemd-journal groups. If it is not, the component still starts without error and simply collects no entries, so the permission check has to be part of the build rather than a troubleshooting step.

  • Confirm the service user: check the systemd unit file to see which account runs Alloy, since some packages or custom units use a different name.
  • Add both groups: append the adm and systemd-journal groups to the alloy account with your standard user management tooling, keeping any existing memberships.
  • Restart the service: group membership is applied when a process starts, so restart Alloy after the change.
  • Test the read as the service user: run a short journal query as alloy to confirm that entries come back before you rely on the pipeline.
  • Watch the destination: because the failure is silent, confirm that streams for the units you expect appear in Loki.

Check that a LogQL query in Grafana returns recent entries for a known unit, and keep the group list in your configuration management so a rebuild does not drop it. The Alloy reference for loki.source.journal lists the requirement in full.

Security controls for journal logs in transit and at rest

Journal logs often carry more than operators expect, including credentials printed by scripts, connection strings and personal data in application messages. The controls below cover what the Alloy process can read, how its traffic reaches Loki, how tenants stay apart and what ends up in labels that Loki indexes.

Least-privilege group membership

Add the alloy user only to the groups the journal read path needs, which are adm and systemd-journal, and confirm no other supplementary groups were inherited from a package or a previous agent. Membership in these groups grants read access to journal data for every unit on the host, so the agent's group list is a security decision, not a setup detail. Review it after each package upgrade that touches the Alloy service account.

Limiting reads beyond the journal

Membership in the journal groups does not restrict which journal entries are read, so the Alloy process can see everything the journal holds. Keep the Alloy configuration to the journal source and its intended file paths, and make sure no other component in the same Alloy instance reads host files such as application logs or secret stores. Check the systemd unit's filesystem and privilege settings against what the pipeline actually needs.

TLS and authentication to Loki

Loki has no built-in authentication layer, so the push endpoint must sit behind an authenticating reverse proxy that terminates TLS. Configure Alloy's Loki writer with the proxy's HTTPS address, the credentials or client certificate the proxy expects, and a trusted CA bundle. Confirm that plain HTTP to Loki is blocked on the network path, since journal messages travel in that request body.

Loki authentication docs

Tenant separation with X-Scope-OrgID

When auth_enabled is true, Loki uses the X-Scope-OrgID header to decide which tenant receives each write and which tenant a query can read. Set the tenant per host group or environment in the Alloy writer, and have the reverse proxy overwrite any client-supplied value so a host cannot write into or read from another team's tenant. Test this with a host from one tenant attempting a query against another.

Loki multi-tenancy docs

Keeping secrets out of labels

Labels such as unit and hostname are indexed and shown in every stream selector, so a value copied from a journal field into a label spreads to every dashboard and query result. Keep label values to stable identifiers and leave message text, command lines and request parameters in the log line. Journal messages can still contain passwords, tokens and personal data, so plan retention and query access in Loki for that content, not only for labels.

Why journal collection shows no error and no data

This table lists the failures that make journal collection look healthy while nothing reaches Loki, with the cause and the specific check that confirms each one. Work down the rows in order, since the first two are the most common silent failures on a new host. Each fix points back to a check in the setup steps.

SymptomLikely causeFix
Component starts, no entries appearThe alloy user is missing the adm or systemd-journal group, so the journal is unreadable without any errorRun id alloy to confirm both groups, add them with usermod -aG, then restart Alloy
No entries after a group changeAlloy kept the group list it had at process startRestart the Alloy service so the new group memberships apply to the running process
Entries arrive with no unit label or with a blank oneRelabel rules drop or rename the __journal__systemd_unit source label before the writer stepKeep a relabel rule that copies __journal__systemd_unit to a unit label, then check the label in Grafana Explore
Only some hosts or units show dataFilters or a units list in the source block exclude the services you expectedRemove the filter temporarily, confirm all units arrive, then reapply the narrower selection
Pushes rejected with a tenant or auth errorauth_enabled is true and the writer does not send X-Scope-OrgID, or the authenticating proxy blocks the pushSet the tenant header in the Loki write block and confirm the proxy forwards it and allows the push path
Pushes rejected for too many streams or labelsJournal fields such as PID, message or hostname were promoted to labels, raising stream cardinalityKeep labels to unit and host, move other fields to structured metadata or drop them in the pipeline

Questions teams ask before collecting journal logs into Loki

Can our own team collect journal logs into Loki without outside help?

Yes, if you have someone comfortable with Linux service accounts, group membership and Grafana Alloy configuration. The component itself is small: Alloy reads the systemd journal through loki.source.journal and forwards entries to Loki. The harder part is the surrounding work: deciding which units and labels to keep, confirming the alloy user can read the journal on every host, and wiring the Loki endpoint and any tenant header. Teams with a few hosts and an existing Loki cluster often do this in-house. Teams that need to standardize the pattern across many hosts, or that must document it for an assessor, often bring in a partner for the design and review, then run the rollout themselves.

What drives the effort of journal log collection?

Effort follows the number of hosts, the mix of operating systems and runtimes, and how much the logs must be separated and protected. Each of these adds work:

  • Host count and configuration management: more hosts mean more consistent Alloy configuration and group membership changes to roll out and verify.
  • Runtimes and units: services that log in different patterns need label decisions and testing per unit.
  • Multi-tenancy: if teams or customers need separate tenants, each host's Alloy configuration must send the correct X-Scope-OrgID header.
  • Hardening: a host that must follow a security baseline needs the permission change reviewed and documented.
What does the work need from our team before it starts?

Plan for four inputs: administrative access to the target hosts, a reachable Loki endpoint with its address and authentication details, a named owner for the Alloy configuration and the security approval for adding the alloy user to the adm and systemd-journal groups. Ask your security team early, because group membership grants read access to log data that may include sensitive values. You will also need a decision on which units to collect and how labels should be named. Confirm with your Loki operators whether auth_enabled is set and which tenant IDs apply, since Loki identifies tenants with the X-Scope-OrgID header on every request.

How long does journal log collection take?

Duration depends on scope, not on a fixed number. A pilot on one or two hosts with a single Loki endpoint is the shortest path, because it proves the permissions and labels before anything is rolled out. Timelines grow with the host count, the number of approval steps, the number of tenants and the number of units that need label review. Ask any provider for a schedule split into design, pilot, rollout and verification phases, with the dependencies on security approval and access to hosts named. A quoted timeline should follow from the written scope rather than a generic estimate.

Should we use Promtail to collect journal logs instead?

No. Promtail reached end of life on March 2, 2026, with no further updates or commercial support, and Grafana directs Promtail users to migrate to Grafana Alloy. For journal collection, use loki.source.journal in Alloy. If your estate already runs Promtail for journal reading, plan the move to Alloy as part of this work, because the configuration does not carry over unchanged and an unsupported agent is a poor base for a regulated environment. The Loki Promtail documentation describes the end-of-life notice and the migration direction.

Why does journal collection return nothing without an error?

Alloy's loki.source.journal component starts without error when the alloy user lacks permission, but it then collects no entries. The fix is to add the alloy user to the adm and systemd-journal groups and restart the service. Because the failure is silent, add a check to your rollout: after the change, confirm that entries from a known unit appear in Loki. Treat the group change as a reviewed security decision, since it grants read access to journal content across the host.

How is a fixed-scope journal logging engagement agreed?

Most DeployOpen engagements are fixed-scope, so scope, deliverables and timelines are agreed in writing before work starts. For journal collection, the written scope normally names the hosts covered, the units and labels to collect, the Loki endpoint and tenant design, the access and approval steps the client will complete, the verification method and the handover documents. A quote follows from that scope. DeployOpen does not publish a price list, so ask for a quote that lists each deliverable and the client inputs it depends on. Ongoing support and upgrades are available as retainers.

How journal entries move from systemd to Loki

The path starts with systemd-journald writing entries on the host, which the alloy user reads through loki.source.journal. Relabeling then sets the labels before loki.write pushes entries to Loki with the tenant header. Grafana queries Loki only through an authenticating reverse proxy. Check the trust boundary: the host side holds the journal and the Alloy credentials, and the Loki side should accept writes only from authenticated sources.

Journal entries flow from the host through Alloy and a reverse proxy into Loki.

How DeployOpen scopes and delivers journal collection

DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, including Grafana Alloy pipelines that read systemd journal logs for Loki. The work starts with a written scope so host access, group membership and label choices are agreed before any change is made.

How we scope

  • Inventory which Linux hosts, distributions and journal sources must be collected into Loki
  • Confirm the alloy service account and how group membership is granted under your access policy
  • Agree the unit, priority and host labels that will be kept, and which fields stay out of labels
  • Record the scope, deliverables and timeline in writing before work starts, as engagements are fixed-scope

How we build

  • Configure loki.source.journal in Alloy on a pilot host and confirm entries arrive in Loki
  • Set the adm and systemd-journal group memberships and verify read access with a test query
  • Roll the configuration out to remaining hosts using your existing configuration management
  • Test that every expected unit appears in Loki, since a missing permission produces no error

How we hand over

  • Deliver the Alloy configuration files, host inventory and permission changes with explanations
  • Document the verification queries your operators can run to confirm collection is still working
  • Provide a runbook for adding hosts, changing labels and diagnosing silent collection gaps
  • Walk your platform and security teams through the handover before the engagement closes

How we support

  • Review Alloy and Loki version changes that affect journal collection before you upgrade
  • Re-check group memberships and collection coverage after OS or configuration changes
  • Ongoing support, upgrades and continuous testing are available as a retainer, priced from the agreed scope

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.