Updates README / Fixes some typos / Update to go 1.15

master
Thomas Maier 2021-02-28 10:43:41 +01:00
rodzic dc1d33cf31
commit 0e65215b17
9 zmienionych plików z 14 dodań i 18 usunięć

3
.gitignore vendored
Wyświetl plik

@ -1,6 +1,3 @@
.vscode
.idea
debug
vendor
Gopkg.lock
xmpp-webhook

Wyświetl plik

@ -1,11 +1,11 @@
FROM golang:1.13-alpine3.10 as builder
FROM golang:1.15-alpine3.13 as builder
MAINTAINER Thomas Maier <contact@thomas-maier.net>
RUN apk add --no-cache git
COPY . /build
WORKDIR /build
RUN GOOS=linux GOARCH=amd64 go build
FROM alpine:3.10
FROM alpine:3.13
RUN apk add --no-cache ca-certificates
COPY --from=builder /build/xmpp-webhook /xmpp-webhook
RUN adduser -D -g '' xmpp-webhook

Wyświetl plik

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 Thomas Maier
Copyright (c) 2021 Thomas Maier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

Wyświetl plik

@ -6,6 +6,7 @@
`xmpp-webhook` currently support:
- Grafana Webhook alerts
- Alertmanager Webhooks
- Slack Incoming Webhooks (Feedback appreciated)
Check https://github.com/tmsmr/xmpp-webhook/blob/master/parser/ to learn how to support more source services.
@ -18,11 +19,12 @@ Check https://github.com/tmsmr/xmpp-webhook/blob/master/parser/ to learn how to
- `XMPP_SKIP_VERIFY` - Skip TLS verification (Optional)
- `XMPP_OVER_TLS` - Use dedicated TLS port (Optional)
- `XMPP_WEBHOOK_LISTEN_ADDRESS` - Bind address (Optional)
- After startup, `xmpp-webhook` tries to connect to the XMPP server and provides the implemented HTTP enpoints (on `:4321`). e.g.:
- After startup, `xmpp-webhook` tries to connect to the XMPP server and provides the implemented HTTP enpoints. e.g.:
```
curl -X POST -d @grafana-webhook-alert-example.json localhost:4321/grafana
curl -X POST -d @slack-compatible-notification-example.json localhost:4321/slack
curl -X POST -d @dev/grafana-webhook-alert-example.json localhost:4321/grafana
curl -X POST -d @dev/alertmanager-example.json localhost:4321/alertmanager
curl -X POST -d @dev/slack-compatible-notification-example.json localhost:4321/slack
```
- After parsing the body in the appropriate `parserFunc`, the notification is then distributed to the configured receivers.
@ -34,10 +36,6 @@ curl -X POST -d @slack-compatible-notification-example.json localhost:4321/slack
- Run: `docker run -e "XMPP_ID=alerts@example.org" -e "XMPP_PASS=xxx" -e "XMPP_RECEIVERS=receiver1@example.org,receiver2@example.org" -p 4321:4321 -d --name xmpp-webhook tmsmr/xmpp-webhook:latest`
## Installation
~~IMPORTANT NOTE: For the sake of simplicity, `xmpp-webhook` is not reconnecting to the XMPP server after a connection-loss. If you use the provided `xmpp-webhook.service` - Systemd will manage the reconnect by restarting the service.~~.
-> https://github.com/mellium/xmpp automatically reconnects after a failure.
- Download and extract the latest tarball (GitHub release page)
- Install the binary: `install -D -m 744 xmpp-webhook /usr/local/bin/xmpp-webhook`
- Install the service: `install -D -m 644 xmpp-webhook.service /etc/systemd/system/xmpp-webhook.service`
@ -62,6 +60,7 @@ systemctl start xmpp-webhook
- Clone the sources
- Change in the project folder:
- Build `xmpp-webhook`: `go build`
- `dev/xmpp-dev-stack` starts Prosody (With "auth_any" and "roster_allinall" enabled) and two XMPP-clients for easy testing
## Need help?
Feel free to contact me!

2
go.mod
Wyświetl plik

@ -9,4 +9,4 @@ require (
mellium.im/xmpp v0.18.0
)
go 1.13
go 1.15

Wyświetl plik

@ -166,7 +166,7 @@ func main() {
}
}()
// initialize handlers with accociated parser functions
// initialize handlers with associated parser functions
http.Handle("/grafana", newMessageHandler(messages, parser.GrafanaParserFunc))
http.Handle("/slack", newMessageHandler(messages, parser.SlackParserFunc))
http.Handle("/alertmanager", newMessageHandler(messages, parser.AlertmanagerParserFunc))

Wyświetl plik

@ -29,7 +29,7 @@ func AlertmanagerParserFunc(r *http.Request) (string, error) {
return "", errors.New(parseErr)
}
// contruct alert message
// construct alert message
var message string
for _, alert := range payload.Alerts {
if alert.Status == "resolved" {

Wyświetl plik

@ -27,7 +27,7 @@ func GrafanaParserFunc(r *http.Request) (string, error) {
return "", errors.New(parseErr)
}
// contruct alert message
// construct alert message
var message string
switch alert.State {
case "ok":

Wyświetl plik

@ -29,7 +29,7 @@ func SlackParserFunc(r *http.Request) (string, error) {
return "", errors.New(parseErr)
}
// contruct alert message
// construct alert message
message := alert.Text
for _, attachment := range alert.Attachments {
if len(message) > 0 {