vshn / signalilo

Forward alerts from Prometheus Alertmanager to Icinga2 via Webhooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No spaces in validateServiceName allowed

Decstasy opened this issue · comments

Hello,

I was searching for a while, after I realized, that signalilo cannot handle alertnames with spaces correctly.
You can repreduce my problem if you fire an alert with an Alertname like "This is a test".

The regex https://github.com/vshn/signalilo/blob/master/webhook/icinga.go#L28 prevents that anything with a space will be sent to icinga2.
Is there a reason, that there is no string replace to convert spaces to underscores or just properly encode the spaces to the GET method for the Icinga2 API?

I would love to see this fixed, since many people are using spaces in their names.

Thanks and best regards,
Dennis

One more thing: If the validation failed in the first place, signalilo is still trying to create the service and gets an 500 error from the Icinga2 API, that there is no service name given.

status": "Object could not be created."}​​​​​]}​​​​​{​​​​​"level":"error","msg":"Error in checkOrCreateService for : create /services/signalilo! : 500 Internal Server Error - Object could not be created. Error: Object name must not be empty.

Hi Dennis,

Thanks for the report. To address your initial question: we've simply not encountered the case of having spaces in the Alertname until now, so we never considered this when generating the internal service name for Icinga2.

Looking at the service name computation and validation and subsequent Icinga2 API calls, I see a whole bunch of issues. I'll try to find some time to clean up the implementation soon.

Best regards,
-- Simon