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

feat: add rocketchat notifier #3600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TheMeier
Copy link
Contributor

This adds native support for Rocketchat notifications. It uses the Rocketchat REST API. For authentication access tokens are used. This is a solution for #3546

@TheMeier TheMeier force-pushed the rocketchat branch 6 times, most recently from 90e581d to 11915f0 Compare November 12, 2023 16:10
Copy link
Contributor

@grobinson-grafana grobinson-grafana left a comment

Choose a reason for hiding this comment

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

I'm not a maintainer but in general looks good! You might have to remove use of the SDK as 1. these tend to be quite large and 2. all of the other integrations avoid using their respective SDKs.

However, I'd wait until @simonpasquier or @gotjosh review before making further changes as I don't want to give you incorrect advice! 🙂

config/notifiers.go Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
notify/rocketchat/rocketchat.go Outdated Show resolved Hide resolved
notify/rocketchat/rocketchat.go Outdated Show resolved Hide resolved
@TheMeier
Copy link
Contributor Author

I'm not a maintainer but in general looks good! You might have to remove use of the SDK as 1. these tend to be quite large and 2. all of the other integrations avoid using their respective SDKs.

However, I'd wait until @simonpasquier or @gotjosh review before making further changes as I don't want to give you incorrect advice! 🙂

@grobinson-grafana thanks for your feedback.
Actually since I had a night to sleep on it, i already am planning to refactor it since it feels so alien, and some things do not really work like the retry mechanism.
So I will probably set this to Draft and work on it a bit more in the coming days.

@gotjosh gotjosh self-assigned this Nov 14, 2023
@TheMeier TheMeier marked this pull request as draft November 15, 2023 09:28
@TheMeier TheMeier force-pushed the rocketchat branch 5 times, most recently from d6a5e1c to 2e16289 Compare November 18, 2023 16:03
@TheMeier TheMeier marked this pull request as ready for review November 18, 2023 16:03
@TheMeier
Copy link
Contributor Author

I removed the rocketchat SDK. Do you prefer that i squash the commits in this PR?

@TheMeier TheMeier force-pushed the rocketchat branch 2 times, most recently from 4e86183 to c4a7876 Compare February 13, 2024 18:21
@TheMeier
Copy link
Contributor Author

@roidelapluie I am aware you have a lot on your plate. I just wanted to kindly ask if there is any chance of this getting some love, since you mentioned some interest in the referenced issue.

@TheMeier
Copy link
Contributor Author

TheMeier commented Mar 9, 2024

@gotjosh can I get a review please?

@TheMeier TheMeier force-pushed the rocketchat branch 5 times, most recently from c295ec1 to 6255464 Compare March 24, 2024 19:31
@grobinson-grafana
Copy link
Contributor

@TheMeier I started to look at this, but I'm not sure how to test this. I've run into a number of issues getting RocketChat to run on Apple M1 as it seems there are no docker images for linux/arm64. I've also tried building from source and I'm running into a number of errors with yarn. I'm following these instructions here.

Have you been able to test these changes?

@TheMeier
Copy link
Contributor Author

@grobinson-grafana I have tested them with a real-live inhouse rocketchat server.

Copy link
Contributor

@grobinson-grafana grobinson-grafana left a comment

Choose a reason for hiding this comment

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

I did a review, just a couple of changes. I would still like to be able to test it too before I approve. @gotjosh how would we best go about getting a trial of RocketChat SaaS?

config/config.go Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
config/notifiers.go Outdated Show resolved Hide resolved
notify/rocketchat/rocketchat.go Outdated Show resolved Hide resolved
notify/rocketchat/rocketchat.go Outdated Show resolved Hide resolved
notify/rocketchat/rocketchat.go Show resolved Hide resolved
notify/rocketchat/rocketchat.go Show resolved Hide resolved
if err := json.NewEncoder(&buf).Encode(body); err != nil {
return false, err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/%s", n.conf.APIURL.String(), "api/v1/chat.postMessage"), &buf)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use the postJSONFunc like in https://github.com/prometheus/alertmanager/blob/main/notify/slack/slack.go#L208. I think we can update it to accept headers or even *http.Request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please point me at how to do this correctly? notify.PostJSON is used by some integrations but not all. Do you suggest I should change the function signature of notify.PostJSON, and thus change notify.post and notify.request?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of adding a headers argument which would be of the type http.Headers. Let me check to see how big of a change it is, as I might do it in a separate PR which you can then rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was tinkering with exactly that yesterday evening and to me it looked like a very substantial change, thus the question.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what I thought #3776.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jep looks pretty much how I expected/encountered on tinkering

Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
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

Successfully merging this pull request may close these issues.

None yet

3 participants