-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some code around slack notification, still work remaining to do
Signed-off-by: Kedar Vijay Kulkarni <[email protected]>
- Loading branch information
Kedar Vijay Kulkarni
committed
Nov 9, 2021
1 parent
38905e6
commit 8883a86
Showing
8 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
config/prometheus.yaml | ||
config/*.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package Notify | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/slack-go/slack" | ||
) | ||
|
||
type SlackConfig struct { | ||
UserID string `json:"userID"` | ||
ChannelID string `json:"channelID"` | ||
SlackToken string `json:"slackToken"` | ||
} | ||
|
||
// TODO Add function to Read Slack Config | ||
|
||
func (s SlackConfig) SlackNotify(message string) { | ||
api := slack.New(s.SlackToken, slack.OptionDebug(true)) | ||
msgText := slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("Hi <@%s>, following query failed:%s", s.UserID, message), false, false) | ||
msgSection := slack.NewSectionBlock(msgText, nil, nil) | ||
msgBlock := slack.MsgOptionBlocks( | ||
msgSection, | ||
) | ||
_, _, _, err := api.SendMessage(s.ChannelID, msgBlock) | ||
if err != nil { | ||
fmt.Printf("%s\n", err) | ||
return | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
slackToken: xoxb-<token> | ||
channelID: C0XXXXXXXXX | ||
userID: U0XXXXXXXXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters