Skip to content

Commit

Permalink
Extract Slack webhook values to config (jpweber#6)
Browse files Browse the repository at this point in the history
* Fix Dockerfile build paths

Signed-off-by: Chris O'Brien <[email protected]>

* Move Slack webhook config to env vars

Signed-off-by: Chris O'Brien <[email protected]>

* Add new env vars to README

Signed-off-by: Chris O'Brien <[email protected]>
  • Loading branch information
chrisob authored and jpweber committed Nov 21, 2019
1 parent 6968124 commit 14eed06
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.11.3-alpine3.8 AS build
COPY . /go/src/app
COPY . /go/src/github.com/jpweber/cole

WORKDIR /go/src/app
WORKDIR /go/src/github.com/jpweber/cole
RUN apk --update upgrade && \
apk add ca-certificates && \
update-ca-certificates && \
Expand All @@ -15,5 +15,5 @@ RUN apk --update upgrade && \
apk add ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
COPY --from=build /go/src/app/app /cole
COPY --from=build /go/src/github.com/jpweber/cole/app /cole
CMD ["/cole"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ There is a forthcoming blog post on [jpweber.io](http://jpweber.io/blog
# Interval = 10
# HTTPEndpoint = "https://hooks.slack.com/services/..."
# HTTPMethod = "POST"
# SlackChannel = "#general"
# SlackUsername = "Cole - DeadManSwitch Monitor"
# SlackIcon = ":monkey_face:"


# PagerDuty
Expand All @@ -83,6 +86,9 @@ PDIntegrationKey = "5353fb993888441811111111111"
* `HTTP_METHOD`
* `EMAIL_ADDR`
* `PD_KEY`
* `SLACK_CHANNEL`
* `SLACK_USERNAME`
* `SLACK_ICON`
## Example Prometheus Alert Manager config
Expand Down
3 changes: 3 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type Conf struct {
HTTPMethod string `env:"HTTP_METHOD" envDefault:"POST"`
EmailAddress string `env:"EMAIL_ADDR"`
PDIntegrationKey string `env:"PD_KEY"`
SlackChannel string `env:"SLACK_CHANNEL" envDefault:"#general"`
SlackUsername string `env:"SLACK_USERNAME" envDefault:"Cole - DeadManSwitch Monitor"`
SlackIcon string `env:"SLACK_ICON" envDefault:":monkey_face:"`
}

// Reads info from config file
Expand Down
6 changes: 3 additions & 3 deletions notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func (n *NotificationSet) slack() {
log.Println("slack method")
payload := slack.Payload{
Text: "Missed DeadManSwitch Alert - " + n.Message.CommonAnnotations["message"],
Username: "Cole - DeadManSwitch Monitor",
Channel: "#general",
IconEmoji: ":monkey_face:",
Username: n.Config.SlackUsername,
Channel: n.Config.SlackChannel,
IconEmoji: n.Config.SlackIcon,
}
jsonBody, err := json.Marshal(payload)
if err != nil {
Expand Down

0 comments on commit 14eed06

Please sign in to comment.