File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,44 @@ Running tests for all PushBits module is done like this:
3232``` bash
3333make test
3434```
35+
36+ ## Testing the Alertmanager interface
37+
38+ Setting up a local [ Alertmanager] ( https://prometheus.io/docs/alerting/latest/alertmanager/ ) instance is done quickly using Docker or Podman.
39+ We first create the file ` config.yml ` that tells Alertmanger where to send alerts.
40+ Don't forget to replace ` <PB_TOKEN> ` with your application's token.
41+ ``` yaml
42+ route :
43+ receiver : default
44+
45+ receivers :
46+ - name : default
47+ webhook_configs :
48+ - url : http://localhost:8080/alert?token=<PB_TOKEN> # Replace <PB_TOKEN> with your application's token.
49+ ` ` `
50+
51+ We mount this file into a container running Alertmanager.
52+ For convenience, let's use this Makefile:
53+ ` ` ` make
54+ CONTAINER_NAME := alertmanager
55+ IMAGE_NAME := quay.io/prometheus/alertmanager
56+
57+ .PHONY : up
58+ up :
59+ podman run --name $(CONTAINER_NAME) --rm --network host -v $(PWD)/config.yml:/etc/alertmanager/alertmanager.yml:Z $(IMAGE_NAME)
60+
61+ .PHONY : down
62+ down :
63+ podman container stop $(CONTAINER_NAME)
64+
65+ .PHONY : send
66+ send :
67+ amtool alert add alertname=testmessage --annotation=title='My Title' --annotation=message='My Message'
68+
69+ .PHONY : setup
70+ setup :
71+ go install github.com/prometheus/alertmanager/cmd/amtool@latest
72+ ` ` `
73+
74+ So first you would install the client using ` make setup`, followed by starting Alertmanager with `make up`.
75+ When PushBits is running, a `make send` would create a new alert in Alertmanager, which is then passed to PushBits via the defined webhook.
You can’t perform that action at this time.
0 commit comments