I’m trying to scrape a caddy access.log file with the following basic config (I have checked, the alloy container can access /caddy-logs/access.log)
discovery.file "caddy_logs" {
files = ["/caddy-logs/*.log"]
}
discovery.relabel "caddy_logs_relabel" {
targets = discovery.file.caddy_logs.targets
rule {
target_label = "job"
replacement = "caddy-access"
}
rule {
target_label = "host"
replacement = "dtsc-iwu"
}
rule {
target_label = "platform"
replacement = "docker-volume"
}
}
loki.source.file "caddy_logs" {
targets = discovery.relabel.caddy_logs_relabel.output
forward_to = [loki.process.caddy_parser.receiver]
tail_from_end = true
}
loki.process "caddy_parser" {
forward_to = [loki.write.default.receiver]
stage.logfmt {
mapping = {
"extra" = "",
}
}
}
When starting the alloy container, I get this:
alloy | panic: discovery.File.readFile: unhandled file extension ".log"
alloy |
alloy | goroutine 406 [running]:
alloy | github.com/prometheus/prometheus/discovery/file.(*Discovery).readFile(0xc001dfeee0, {0xc001d8c798, 0x16})
alloy | /go/pkg/mod/github.com/grafana/prometheus@v1.8.2-0.20250312141819-a2b6722387bf/discovery/file/file.go:406 +0x745
alloy | github.com/prometheus/prometheus/discovery/file.(*Discovery).refresh(0xc001dfeee0, {0xd04c840, 0xc001e02c30}, 0xc001f12620)
alloy | /go/pkg/mod/github.com/grafana/prometheus@v1.8.2-0.20250312141819-a2b6722387bf/discovery/file/file.go:338 +0x125
alloy | github.com/prometheus/prometheus/discovery/file.(*Discovery).Run(0xc001dfeee0, {0xd04c840, 0xc001e02c30}, 0xc001f12620)
alloy | /go/pkg/mod/github.com/grafana/prometheus@v1.8.2-0.20250312141819-a2b6722387bf/discovery/file/file.go:250 +0xe5
alloy | github.com/grafana/alloy/internal/component/discovery.(*discovererWithMetrics).Run(0xc001dea6d0?, {0xd04c840?, 0xc001e02c30?}, 0xc001e45c80?)
alloy | /src/alloy/internal/component/discovery/discovery_metrics.go:46 +0x25
alloy | github.com/grafana/alloy/internal/component/discovery.(*Component).runDiscovery.func1()
alloy | /src/alloy/internal/component/discovery/discovery.go:177 +0x31
alloy | created by github.com/grafana/alloy/internal/component/discovery.(*Component).runDiscovery in goroutine 361
alloy | /src/alloy/internal/component/discovery/discovery.go:176 +0x185
What am I missing?