Grafana Alloy – Part 1: Replacing Promtail
Why Grafana Alloy
This first article will discuss the migration from Promtail to Alloy.
From Promtail to Alloy – How to Migrate
As already mentioned Grafana Alloy is shipped starting with SLES 15 SP7. This means it can be install directly from the SUSE repositories:
# zypper in alloy
The configuration file can be found under:
/etc/alloy/config.alloy
Grafana Alloy has a build-in convert command which helps you to migrate to the new configuration style.
This utility is designed to smoothly translate your existing Promtail configuration into the new Alloy syntax. The command is quite easy to understand. All you need is the Promtail config file and an output path.
alloy convert --source-format=promtail --output=<OUTPUT_CONFIG_PATH> /etc/loki/promtail.yaml
Comparing the configurations
First of all, let us take a look at a typical Promtail configuration. In our example, we use a simple one that only captures the system’s journald logs:
/etc/loki/promtail.yaml:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /var/lib/promtail/positions.yaml
# Writer (3)
clients:
- url: http://loki-host:3100/loki/api/v1/push
# Source (1)
scrape_configs:
- job_name: journal
journal:
max_age: 24h
labels:
job: loki_messages
# Processor (2)
relabel_configs:
- source_labels: ['__journal__systemd_unit']
target_label: 'unit'
- source_labels: ['__journal__hostname']
target_label: 'host'
- source_labels: ['__journal__pid']
target_label: 'pid'
- source_labels: ['__journal__kernel_device']
target_label: 'kernel_device'
- source_labels: ['__journal__priority']
target_label: 'prio'
Source
On Promtail
# Source (1)
scrape_configs:
- job_name: journal
journal:
max_age: 24h
labels:
job: systemd-journal
On Alloy
// Source (1)
loki.source.journal "journal" {
max_age="24h0m0s"
relabel_rules=discovery.relabel.journal.rules
forward_to=[loki.write.default.receiver]
labels={
job="systemd-journal",
}
}
- `relabel_rules` is pointing to the relabel component (Processors).
- `forward_to` is pointing to the next component (Writers).
Processors
On Promtail
# Processor (2) relabel_configs: - source_labels: ['__journal__systemd_unit'] target_label: 'unit' - source_labels: ['__journal__hostname'] target_label: 'host' - source_labels: ['__journal__pid'] target_label: 'pid' - source_labels: ['__journal__kernel_device'] target_label: 'kernel_device' - source_labels: ['__journal__priority'] target_label: 'prio'
On Alloy
// Processor (2)
discovery.relabel "journal" {
targets=[]
rule{
source_labels=["__journal__systemd_unit"]
target_label="unit"
}
rule {
source_labels=["__journal__hostname"]
target_label="host"
}
rule {
source_labels=["__journal__pid"]
target_label="pid"
}
rule {
source_labels=["__journal__kernel_device"]
target_label="kernel_device"
}
rule {
source_labels=["__journal__priority"]
target_label="prio"
}
}
Writers
On Promtail
# Writer (3) clients: - url: http://loki-host:3100/loki/api/v1/push
On Alloy
// Writer (3)
loki.write "default" {
endpoint{
url="http://loki-host:3100/loki/api/v1/push"
}
external_labels = {}
}
The Complete config for Alloy
// Source (1)
loki.source.journal "journal" {
max_age="24h0m0s"
relabel_rules=discovery.relabel.journal.rules
forward_to=[loki.write.default.receiver]
labels={
job="loki_messages",
}
}
// Processor (2)
discovery.relabel "journal" {
targets=[]
rule{
source_labels=["__journal__systemd_unit"]
target_label="unit"
}
rule {
source_labels=["__journal__hostname"]
target_label="host"
}
rule {
source_labels=["__journal__pid"]
target_label="pid"
}
role {
source_labels=["__journal__kernel_device"]
target_label="kernel_device"
}
rule {
source_labels=["__journal__priority"]
target_label="prio"
}
}
// Writer (3)
loki.write "default" {
endpoint{
url="http://loki-host:3100/loki/api/v1/push"
}
external_labels = {}
}
Conclusion
Links to documentations
Related Articles
Apr 25th, 2025
The Total Kubernetes Troubleshooting Guide
Jul 11th, 2025