Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
summerwind committed Nov 11, 2017
0 parents commit fdd1902
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.DS_Store
sentry-gateway
dist/
vendor/
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine:3.4
MAINTAINER Moto Ishizawa "summerwind.jp"

COPY ./sentry-gateway /bin/sentry-gateway

ENTRYPOINT ["sentry-gateway"]
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2017 Moto Ishizawa

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
NAME=alertmanager-sentry-gateway
VERSION=0.1.0
COMMIT=$(shell git rev-parse --verify HEAD)

PACKAGES=$(shell go list ./...)
BUILD_FLAGS=-ldflags "-X main.VERSION=$(VERSION) -X main.COMMIT=$(COMMIT)"

.PHONY: build test container clean

build: vendor
go build $(BUILD_FLAGS) sentry-gateway.go

test: vendor
go test -v $(PACKAGES)
go vet $(PACKAGES)

container:
GOARCH=amd64 GOOS=linux go build $(BUILD_FLAGS) sentry-gateway.go
docker build -t summerwind/$(NAME):latest -t summerwind/$(NAME):$(VERSION) .
rm -rf sentry-gateway

clean:
rm -rf sentry-gateway
rm -rf dist

dist:
mkdir -p dist

GOARCH=amd64 GOOS=darwin go build $(BUILD_FLAGS) sentry-gateway.go
tar -czf dist/${NAME}_darwin_amd64.tar.gz sentry-gateway
rm -rf sentry-gateway

GOARCH=amd64 GOOS=linux go build $(BUILD_FLAGS) sentry-gateway.go
tar -czf dist/${NAME}_linux_amd64.tar.gz sentry-gateway
rm -rf sentry-gateway

GOARCH=arm64 GOOS=linux go build $(BUILD_FLAGS) sentry-gateway.go
tar -czf dist/${NAME}_linux_arm64.tar.gz sentry-gateway
rm -rf sentry-gateway

GOARCH=arm GOOS=linux go build $(BUILD_FLAGS) sentry-gateway.go
tar -czf dist/${NAME}_linux_arm.tar.gz sentry-gateway
rm -rf sentry-gateway

vendor:
glide install
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# alertmanager-sentry-gateway

alertmanager-sentry-gateway is a webhook gateway for [Alertmanager](https://github.com/prometheus/alertmanager). This gateway recives webhooks from Alertmanager and sends alert information as an event to [Sentry](https://sentry.io).

## Install

### Just want the binary?

Go to the [releases page](https://github.com/summerwind/alertmanager-sentry-gateway/releases), find the version you want, and download the tarball file.

### Run as container?

```
$ docker pull summerwind/alertmanager-sentry-gateway:latest
```

### Building binary yourself

To build the binary you need to install [Go](https://golang.org/) and [Glide](https://github.com/Masterminds/glide).

```
$ make
```

## Usage

Sentry's DSN is required to run this gateway.

```
$ sentry-gateway --dsn ${SENTRY_DSN}
```

Event body of Sentry can be customized with a template file as follows. The data passed to the template file is an [Alert](https://godoc.org/github.com/prometheus/alertmanager/template#Alert) of Alertmanager.

```
$ vim template.tmpl
```
```
{{ .Labels.alertname }} - {{ .Labels.instance }}
{{ .Annotations.description }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
```
```
$ sentry-gateway --dsn ${SENTRY_DSN} --template template.tmpl
```

## Alertmanager Configuration

To enable Alertmanager to send alerts to this gateway you need to configure a webhook in Alertmanager.

```
receivers:
- name: team
webhook_configs:
- url: 'http://127.0.0.1:9096/sentry'
send_resolved: false
```
105 changes: 105 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package: github.com/summerwind/alertmanager-sentry-gateway
import:
- package: github.com/spf13/cobra
version: 7be4beda01ec05d0b93d80b3facd2b6f44080d94
- package: github.com/getsentry/raven-go
version: d3909e6151a9d4ce1baed14ceb3ad7a835f7c91f
- package: github.com/prometheus/alertmanager
version: 133c888ef3644b47a52acbaeffb09f4cc637df1b
Loading

0 comments on commit fdd1902

Please sign in to comment.