Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Telegram alerting provider #232

Merged
merged 1 commit into from
Aug 23, 2021

Conversation

somtochiama
Copy link
Member

Closes #222

@somtochiama somtochiama marked this pull request as draft August 16, 2021 09:30
@stefanprodan
Copy link
Member

@somtochiama please rebase with main branch and solve the conflicts for CI to run.

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rationale behind using shoutrrr for Telegram only, instead of e.g. using a Telegram API library, or using it for other providers as well?

@stefanprodan
Copy link
Member

I think we should look into switching to shoutrrr for the providers that are supported by it. For example people were asking for SlackBot support as an alternative to the classic webhook.

@somtochiama somtochiama force-pushed the telegram-notification branch from 0992874 to ce3bce5 Compare August 16, 2021 14:27
@somtochiama somtochiama marked this pull request as ready for review August 18, 2021 08:20
// The telegram API requires that some special characters are escaped
// in the message string. Docs: https://core.telegram.org/bots/api#formatting-options.
// The function only handles a subset of the characters because the only special
// characters in kubernetes names and namespaces are '-' and '.'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But event.Message can contain any character, for example a kubectl apply error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test this with a Kustomization that fails to apply. I see that we don't post the revision but we should, check how alerts look for Slack: https://fluxcd.io/img/slack-error-alert.png

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to add the event metadata to the message body as separate field in the markdown, maybe a list?

Copy link
Member Author

@somtochiama somtochiama Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the message now looks like with the metadata added

Screenshot 2021-08-18 at 12 35 06 PM

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @somtochiama please squash your commits

Signed-off-by: Somtochi Onyekwere <[email protected]>
@somtochiama somtochiama force-pushed the telegram-notification branch from 8bbacc2 to b0563cb Compare August 19, 2021 07:17
@stefanprodan stefanprodan merged commit dc0d0da into fluxcd:main Aug 23, 2021
@stefanprodan stefanprodan added the area/alerting Alerting related issues and PRs label Aug 26, 2021
@stefanprodan stefanprodan changed the title Add Telegram notification Add Telegram alerting provider Aug 26, 2021
@L3o-pold
Copy link

Seems that's not working for HelmRelease upgrade notification. Unfortunatly I haven't the error from the Telegram return body.

{"level":"info","ts":"2021-09-22T12:19:25.795Z","logger":"event-server","msg":"Dispatching event: Helm upgrade succeeded","reconciler kind":"HelmRelease","name":"ingress-nginx","namespace":"flux-system"}
{"level":"error","ts":"2021-09-22T12:19:25.816Z","logger":"event-server","msg":"failed to send notification","reconciler kind":"HelmRelease","name":"ingress-nginx","namespace":"flux-system","error":"failed to send notification to \"-****\", response status code 400 Bad Request"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alerting Alerting related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Telegram notifications
4 participants