I am having a problem where in my local system - the alloy configuration is working fine, but not in my server.
Issue - in my server, even though no new .gz log file is created, msg=“read lines routine: started” keeps happening for the sync_period that I have given.
Within my local system, msg=“read lines routine: started” happens only if a new .gz file gets created in the directory specified.
Could anyone please look into my issue, I really appreciate your efforts.
My alloy service
alloy:
image: grafana/alloy:latest
container_name: alloy
restart: always
volumes:
- ./config.alloy:/etc/alloy/config.alloy
- /home/abhishek/Documents/logs:/var/log/app-logs:ro #the host directory is set to proper within my server...
command:
- run
- --server.http.listen-addr=0.0.0.0:8083
- /etc/alloy/config.alloy
depends_on:
- loki
networks:
- grafana-network
config.alloy file
local.file_match "log_files" {
path_targets = [{"__path__" = "/var/log/app-logs/*/*.log"}]
ignore_older_than = "24h"
sync_period = "10s"
}
local.file_match "log_gz_files" {
path_targets = [{"__path__" = "/var/log/app-logs/*/*.log.gz"}]
sync_period = "30s"
}
loki.source.file "file_source" {
targets = local.file_match.log_files.targets
tail_from_end = true
file_watch {
min_poll_frequency = "1s"
max_poll_frequency = "30s"
}
forward_to = [loki.process.log_processing.receiver]
}
loki.source.file "file_gz_source" {
targets = local.file_match.log_gz_files.targets
tail_from_end = true
file_watch {
min_poll_frequency = "10s"
max_poll_frequency = "1m"
}
decompression {
enabled = true
initial_delay = "30s"
format = "gz"
}
forward_to = [loki.process.log_processing.receiver]
}
loki.process "log_processing" {
stage.regex {
expression = "/var/log/app-logs/(?P<service>[^/]+)/.*"
source = "filename"
}
stage.labels {
values = { "service_name" = "service" }
}
stage.timestamp {
source = "timestamp"
format = "RFC3339"
action_on_failure = "skip"
}
forward_to = [loki.write.loki_receiver.receiver]
}
loki.write "loki_receiver" {
endpoint {
url = "http://loki:8082/loki/api/v1/push"
}
}