kopia lustrzana https://github.com/tmsmr/xmpp-webhook
changes to go Module dependency management + minor changes
rodzic
67f2f17ea4
commit
617a7a76a4
|
@ -1,3 +0,0 @@
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/emgee/go-xmpp"
|
|
||||||
revision = "efce8dbb971164aec26cb4d5805f0bca2f44b112"
|
|
11
README.md
11
README.md
|
@ -3,7 +3,7 @@
|
||||||
- Based on https://github.com/atomatt/go-xmpp
|
- Based on https://github.com/atomatt/go-xmpp
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
`xmpp-webhook` currently only provides a hook for Grafana. ~~I will implement a `parserFunc` for Prometheus ASAP~~. Check https://github.com/opthomas-prime/xmpp-webhook/blob/master/handler.go to learn how to support more source services.
|
`xmpp-webhook` ~~currently~~ only provides a hook for Grafana. ~~I will implement a `parserFunc` for Prometheus ASAP~~. Check https://github.com/opthomas-prime/xmpp-webhook/blob/master/handler.go to learn how to support more source services.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
- `xmpp-webhook` is configured via environment variables:
|
- `xmpp-webhook` is configured via environment variables:
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
- 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 (on `:4321`). e.g.:
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -X POST -d @grafana-alert.json localhost:4321/grafana
|
curl -X POST -d @grafana-webhook-alert-example.json localhost:4321/grafana
|
||||||
```
|
```
|
||||||
- After parsing the body in the appropriate `parserFunc`, the notification is then distributed to the configured receivers.
|
- After parsing the body in the appropriate `parserFunc`, the notification is then distributed to the configured receivers.
|
||||||
|
|
||||||
|
@ -40,10 +40,9 @@ systemctl start xmpp-webhook
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
- Get the sources: `go get -u github.com/opthomas-prime/xmpp-webhook`
|
- Dependencies are managed via Go Modules (https://github.com/golang/go/wiki/Modules).
|
||||||
- Install `dep`: https://github.com/golang/dep
|
- Clone the sources
|
||||||
- Change in the project folder: `cd $GOPATH/src/github.com/opthomas-prime/xmpp-webhook`
|
- Change in the project folder:
|
||||||
- Populate `vendor` folder: `dep ensure`
|
|
||||||
- Build `xmpp-webhook`: `go build`
|
- Build `xmpp-webhook`: `go build`
|
||||||
|
|
||||||
## Need help?
|
## Need help?
|
||||||
|
|
|
@ -62,9 +62,9 @@ func grafanaParserFunc(r *http.Request) (string, error) {
|
||||||
var message string
|
var message string
|
||||||
switch alert.State {
|
switch alert.State {
|
||||||
case "ok":
|
case "ok":
|
||||||
message = "8-) " + alert.Title
|
message = ":) " + alert.Title
|
||||||
default:
|
default:
|
||||||
message = ":'-( " + alert.Title + "\n" + alert.Message + "\n" + alert.RuleURL
|
message = ":( " + alert.Title + "\n" + alert.Message + "\n" + alert.RuleURL
|
||||||
}
|
}
|
||||||
|
|
||||||
return message, nil
|
return message, nil
|
||||||
|
|
2
main.go
2
main.go
|
@ -85,7 +85,7 @@ func main() {
|
||||||
xc.Out <- xmpp.Message{
|
xc.Out <- xmpp.Message{
|
||||||
To: r,
|
To: r,
|
||||||
Body: []xmpp.MessageBody{
|
Body: []xmpp.MessageBody{
|
||||||
xmpp.MessageBody{
|
{
|
||||||
Value: m,
|
Value: m,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Ładowanie…
Reference in New Issue