I’m using Grafana Alloy to send JSON logs from a Caddy webserver to Loki. I’m able to extract the timestamp with the config below. However, I would like to remove original timestamp ts
from the JSON log before sending it to Loki. I couldn’t figure out what function/module was available to do this. Can the JSON log be modified before sending? Thanks.
local.file_match "caddy" {
path_targets = [{
__address__ = "localhost",
__path__ = "/var/log/access.log",
job = "caddy",
}]
}
loki.process "caddy" {
forward_to = [loki.write.default.receiver]
stage.json {
expressions = {
level = "level",
timestamp = "ts",
status = "status",
}
}
stage.labels {
values = {
level = null,
status = null,
}
}
stage.timestamp {
source = "timestamp"
format = "Unix"
}
}
loki.source.file "caddy" {
targets = local.file_match.caddy.targets
forward_to = [loki.process.caddy.receiver]
}
loki.write "default" {
endpoint {
url = "..."
}
external_labels = {}
}