My config.alloy
discovery.docker "oja" {
host = "unix:///var/run/docker.sock"
refresh_interval = "5s"
}
discovery.relabel "oja" {
targets = discovery.docker.oja.targets
rule {
source_labels = ["__meta_docker_container_name"]
regex = "/(.*)"
target_label = "container"
}
rule {
source_labels = ["__meta_docker_container_name"]
regex = "oja-(backend|app|storefront|db)"
action = "keep"
}
rule {
target_label = "job"
replacement = "oja-docker"
}
}
loki.source.docker "oja" {
host = "unix:///var/run/docker.sock"
targets = discovery.relabel.oja.output
relabel_rules = discovery.relabel.oja.rules
forward_to = [loki.write.oja.receiver]
refresh_interval = "5s"
labels = {
"environment" = "dev",
"source" = "docker",
}
}
loki.write "oja" {
endpoint {
url = env("LOKI_URL")
basic_auth {
username = env("LOKI_USERNAME")
password = env("LOKI_PASSWORD")
}
}
external_labels = {
"cluster" = "oja-local",
}
}
livedebugging {
enabled = true
}
My docker compose
services:
# List of services
alloy:
image: grafana/alloy:boringcrypto
container_name: alloy
restart: unless-stopped
volumes:
- ./config.alloy:/etc/alloy/config.alloy:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
# Optional: persist positions (so Alloy doesn't re-send old logs on restart)
- alloy_positions:/positions
command: run --server.http.listen-addr=0.0.0.0:12345 /etc/alloy/config.alloy
env_file:
- .env
ports:
- "12345:12345"
Alloy service starts up fine, tail log
alloy | ts=2026-05-21T10:08:44.41202417Z level=info boringcrypto_enabled=true
alloy | ts=2026-05-21T10:08:44.39941007Z level=info source=/go/pkg/mod/github.com/!kim!machine!gun/automemlimit@v0.7.5/memlimit/memlimit.go:175 msg="memory is not limited, skipping" package=github.com/KimMachineGun/automemlimit/memlimit
alloy | ts=2026-05-21T10:08:44.412169807Z level=info msg="no peer discovery configured: both join and discover peers are empty" service=cluster
alloy | ts=2026-05-21T10:08:44.412178474Z level=info msg="running usage stats reporter"
alloy | ts=2026-05-21T10:08:44.409316495Z level=warn source=/src/alloy/internal/runtime/internal/controller/component_references.go:58 msg="this stdlib function is deprecated; please refer to the documentation for updated usage and alternatives" controller_path=/ controller_id="" function=env
alloy | ts=2026-05-21T10:08:44.409329891Z level=warn source=/src/alloy/internal/runtime/internal/controller/component_references.go:58 msg="this stdlib function is deprecated; please refer to the documentation for updated usage and alternatives" controller_path=/ controller_id="" function=env
alloy | ts=2026-05-21T10:08:44.409334851Z level=warn source=/src/alloy/internal/runtime/internal/controller/component_references.go:58 msg="this stdlib function is deprecated; please refer to the documentation for updated usage and alternatives" controller_path=/ controller_id="" function=env
alloy | ts=2026-05-21T10:08:44.409458115Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:201 msg="starting complete graph evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d
alloy | ts=2026-05-21T10:08:44.4098827Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=discovery.docker.oja duration=411.149µs
alloy | ts=2026-05-21T10:08:44.410215033Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=discovery.relabel.oja duration=319.418µs
alloy | ts=2026-05-21T10:08:44.410297425Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=remotecfg duration=74.206µs
alloy | ts=2026-05-21T10:08:44.412290674Z level=info msg="applying non-TLS config to HTTP server" service=http
alloy | ts=2026-05-21T10:08:44.410327144Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=http duration=22.344µs
alloy | ts=2026-05-21T10:08:44.410338486Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=cluster duration=4.739µs
alloy | ts=2026-05-21T10:08:44.410357684Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=livedebugging duration=14.097µs
alloy | ts=2026-05-21T10:08:44.410361722Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=ui duration=1.212µs
alloy | ts=2026-05-21T10:08:44.410477379Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=labelstore duration=111.52µs
alloy | ts=2026-05-21T10:08:44.411425493Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=loki.write.oja duration=936.612µs
alloy | ts=2026-05-21T10:08:44.411997809Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=loki.source.docker.oja duration=561.274µs
alloy | ts=2026-05-21T10:08:44.412015614Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=tracing duration=10.831µs
alloy | ts=2026-05-21T10:08:44.412436211Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=logging duration=416.158µs
alloy | ts=2026-05-21T10:08:44.412481419Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:218 msg="finished node evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d node_id=otel duration=29.908µs
alloy | ts=2026-05-21T10:08:44.412494144Z level=info source=/src/alloy/internal/runtime/internal/controller/loader.go:205 msg="finished complete graph evaluation" controller_path=/ controller_id="" trace_id=f980417fddfc8900660188436f734b0d duration=3.615681ms
alloy | ts=2026-05-21T10:08:44.413864075Z level=info source=/src/alloy/internal/runtime/alloy.go:287 msg="scheduling loaded components and services" controller_id=""
alloy | ts=2026-05-21T10:08:44.416026646Z level=info msg="failed to register collector with remote server" service=remotecfg id=74b7066c-5496-4c4f-8b9d-21a475a3a986 name="" err="noop client"
alloy | ts=2026-05-21T10:08:44.417982591Z level=info msg="starting cluster node" service=cluster peers_count=0 peers="" advertise_addr=127.0.0.1:12345 minimum_cluster_size=0 minimum_size_wait_timeout=0s
alloy | ts=2026-05-21T10:08:44.419168653Z level=info msg="peers changed" service=cluster peers_count=1 min_cluster_size=0 peers=0f3fbe41f36b
alloy | ts=2026-05-21T10:08:44.449608966Z level=info msg="now listening for http traffic" service=http addr=0.0.0.0:12345
But this does not reflect on the managed service.