Labeling required to receive syslog data and forward to loki

Hi there,
I’m newbie and created an alloy syslog receiver which is supposed to forward data to grafana/loki.

#config.alloy
logging {
    level  = "debug"
    format = "logfmt"
}

loki.source.syslog "syslog" {
  listener {
    address  = "0.0.0.0:1514"
    protocol = "tcp"
    use_rfc5424_message = true
  }
  forward_to = [loki.write.grafana_loki.receiver]
}

loki.write "grafana_loki" {
    endpoint {
        url = "http://loki.intern/loki/api/v1/push"
    }
}

When sending data to alloy then this message is appearing in the logs:

ts=2025-03-01T17:20:57.011031542Z level=error msg="final error sending batch" component_path=/ component_id=loki.write.grafana_loki component=client host=loki.intern status=400 tenant="" error="server returned HTTP status 400 Bad Request (400): error at least one label pair is required per stream"

I tried to add to config.alloy:

loki.source.syslog "syslog" {
   ...
   labels = {
        env = "production"
    }
}

But this does not work either.

How do i solve this?

What is your configuration with labels looking like?

Loki is in General using Port 3100 and you do Not have this in your loki.write. is this expected?

Yes that’s expected, no port needed as i point the default port 80

What is your configuration with labels looking like?
I don’t have any

Check this how to Labelmap Labels and the possible Bug.

That link had helped, Thank you!

1 Like