Skip to content

Alloy emits invalid logfmt with level = "debug" #3477

@IngmarStein

Description

@IngmarStein

What's wrong?

I've configured Alloy to emit debug logs:

logging {
    level = "debug"
    format = "logfmt" 
}

This results in log entries like this:

ts=2025-04-30T11:31:48.998669Z level=debug msg="extracted data debug in logfmt stage" component_path=/ component_id=loki.process.local_logs component=stage type=logfmt "extracted data"="map[filename:/opt/homebrew/var/log/grafana-alloy.log hostname:homelab.localdomain job:grafana-alloy ts:2025-04-30T11:31:48.812936Z]"

Note the extracted data key in quotes which is invalid according to https://docs.appsignal.com/logging/formatting/logfmt.html: "Keys cannot contain spaces, but may contain fullstops (.), underscores (_) and hyphens (-)."

Alloy subsequently fails to decode its own output: ts=2025-04-30T11:31:48.998709Z level=error msg="failed to decode logfmt" component_path=/ component_id=loki.process.local_logs component=stage type=logfmt err="logfmt syntax error at pos 169 on line 1: unexpected '\"'"

Steps to reproduce

Process Alloy debug logs in a loki.process component with a stage.logfmt like this:

    stage.logfmt {
        mapping = {
            "ts" = "",
        }
    }

System information

No response

Software version

No response

Configuration


Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions