Problem is with id part of the message junos@2636.1.1.1.2.36
Per documentation promtail configured with label_structured_data: yes should transform first label to to label __syslog_message_sd_junos_2636.1.1.1.2.36_reason.
But I can't use label like that in relabel config, config as bellow
Unable to parse config: /etc/promtail/config.yml: "__syslog_message_sd_junos_2636.1.1.1.2.36_reason" is not a valid label name. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file
Also '-' in source-address address also causing same problem.
In short, incoming syslog labels are not sanitized enough, or promtail is too strict with name of internal labels.
if t.config.LabelStructuredData && rfc5424Msg.StructuredData != nil {
for id, params := range *rfc5424Msg.StructuredData {
id = strings.ReplaceAll(id, "@", "_")
for name, value := range params {
key := "__syslog_message_sd_" + id + "_" + name
lb.Set(key, value)
}
}
}
Replacing just @ is not enough. Happy to submit pull request with patch but I guess it faster to fix then accept a pull request
Expected behavior
Syslog message like above should be labeled with label reason="idle Timeout"
Observed behavior
Promtail failed to parse config producing error
Unable to parse config: /etc/promtail/config.yml: "__syslog_message_sd_junos_2636.1.1.1.2.36_reason" is not a valid label name. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file
Describe the bug I'm trying to ingest FW flow data from Juniper FW as syslog rfc5424 stream.
An example of the log entry.
Problem is with id part of the message
junos@2636.1.1.1.2.36
Per documentation promtail configured with label_structured_data: yes should transform first label to to label__syslog_message_sd_junos_2636.1.1.1.2.36_reason
.But I can't use label like that in relabel config, config as bellow
Promtail generates error:
Unable to parse config: /etc/promtail/config.yml: "__syslog_message_sd_junos_2636.1.1.1.2.36_reason" is not a valid label name. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file
Also '-' in
source-address
address also causing same problem.In short, incoming syslog labels are not sanitized enough, or promtail is too strict with name of internal labels.
This piece of code from https://github.com/grafana/loki/blob/main/clients/pkg/promtail/targets/syslog/syslogtarget.go is to blame.
Replacing just
@
is not enough. Happy to submit pull request with patch but I guess it faster to fix then accept a pull requestTo Reproduce
Use promtail Config
Expected behavior Syslog message like above should be labeled with label
reason="idle Timeout"
Observed behavior Promtail failed to parse config producing error
Unable to parse config: /etc/promtail/config.yml: "__syslog_message_sd_junos_2636.1.1.1.2.36_reason" is not a valid label name. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file
Environment: