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

Nothing sent via generic webhook to google-chat #65

Open
lgraziosi opened this issue Jan 26, 2024 · 2 comments
Open

Nothing sent via generic webhook to google-chat #65

lgraziosi opened this issue Jan 26, 2024 · 2 comments

Comments

@lgraziosi
Copy link

Hello, I'm trying to use kubewatch to send everything to a google-chat webhook.
I configured everything, and the test seems fine:

root@kubewatch-64577c4cc7-v5thc:/# kubewatch config test
INFO[0000] Custom log formatter: json                   
INFO[0000] Setting custom log formatter to: json        
Testing Handler configs from .kubewatch.yaml
{"level":"info","msg":"No webhook cert is given","time":"2024-01-26T11:42:54Z"}
{"level":"info","msg":"Message successfully sent to https://chat.googleapis.com/v1/spaces/CENSORED at 2024-01-26 11:42:54.488587515 +0000 UTC m=+0.251134753 ","time":"2024-01-26T11:42:54Z"}

But nothing is actually received in the group chat mentioned.
As a reference, something simple as this in python actually sends the message:

from httplib2 import Http
from json import dumps
import sys

def main():
    url = 'https://chat.googleapis.com/v1/spaces/CENSORED'
    bot_message = {
        'text' : sys.argv[1]}

    message_headers = { 'Content-Type': 'application/json; charset=UTF-8'}

    http_obj = Http()

    response = http_obj.request(
        uri=url,
        method='POST',
        headers=message_headers,
        body=dumps(bot_message),
    )

    print(response)

if __name__ == '__main__':
    main()

What could be the issue? Am I missing something?
Thanks.

@RobertSzefler
Copy link

RobertSzefler commented Jan 26, 2024

This will most probably not work with the generic kubewatch webhook handler because the Google Chat webhook API expects a specific JSON format that this handler does not support.

I recently developed a sink in Robusta (it’s based on kubewatch) that is specifically designed to handle Google Chat, you might want to take a look at it.

Another option is to implement a specific handler for Google Chat in the kubewatch codebase, basing on the generic webhook handler. It shouldn't be too hard, the Google Chat webhook requirements are not hard to meet :)

@lgraziosi
Copy link
Author

Another option is to implement a specific handler for Google Chat in the kubewatch codebase, basing on the generic webhook handler. It shouldn't be too hard, the Google Chat webhook requirements are not hard to meet :)

That would be very cool. I certantly would be using it.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants