Skip to content

Commit 19d8a43

Browse files
authored
Add slack app instructions (#55)
* otel config for k8s is currently missing so remove from the landing * update alertmanager configs with slack instructions * emphasize
1 parent a330700 commit 19d8a43

4 files changed

Lines changed: 247 additions & 15 deletions

File tree

src/pages/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"deploy": "Autometrics Stack",
3434
"deploying-prometheus": "Prometheus",
3535
"deploying-explorer": "Explorer",
36-
"deploying-alertmanager": "Alertmanager",
36+
"deploying-alertmanager": "Alertmanager + Slack",
3737
"deploying-otel-collector": "OTel Collector",
3838
"other": {
3939
"type": "separator",

src/pages/deploy.mdx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,17 @@ Each of these components can be easily adopted and deployed to a hosting option
4545
### OpenTelemetry Collector
4646

4747
<Cards num={2}>
48-
<Card
49-
children
50-
icon
51-
title="Kubernetes"
52-
href="/deploying-opentelemetry-collector/kubernetes"
53-
/>
54-
<Card
55-
children
56-
icon
57-
title="Docker"
58-
href="/deploying-opentelemetry-collector/docker"
59-
/>
6048
<Card
6149
children
6250
icon
6351
title="Northflank"
64-
href="/deploying-opentelemetry-collector/northflank"
52+
href="/deploying-otel-collector/northflank"
6553
/>
6654
<Card
6755
children
6856
icon
6957
title="Railway"
70-
href="/deploying-opentelemetry-collector/railway"
58+
href="/deploying-otel-collector/railway"
7159
/>
7260
</Cards>
7361

src/pages/deploying-alertmanager/docker.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,111 @@ alerting:
9696
```
9797

9898
</Steps>
99+
100+
## Add the Autometrics Slack App
101+
102+
Autometrics Slack App is a simple open-source, self-hosted Slack service for Autometrics SLO alerts. It integrates with the Alertmanager and adds more context for each triggered message: the Slack app pulls recent relevant Prometheus data and renders it as an image of the graph on Slack.
103+
104+
Autometrics Slack app is open-source and available as a [Docker image](https://hub.docker.com/r/autometrics/slack-app). Here's a quick guide how to add it and configure it with your Prometheus and Alertmanager setup.
105+
106+
<Steps>
107+
108+
### Create a new Slack application
109+
110+
Go to [https://api.slack.com/apps/](https://api.slack.com/apps/), select your workspace, and create an application **from manifest**.
111+
112+
This is a basic Slack application manifest with limited permissions to post chat messages on channels that the application gets added to. You can find the manifest below:
113+
114+
```yaml filename="manifest.yml"
115+
_metadata:
116+
major_version: 1
117+
minor_version: 0
118+
display_information:
119+
name: Autometrics
120+
description: This bot provides a way for our Autometrics slack-app to communicate with the Slack API.
121+
long_description: |
122+
This bot provides a way for our Autometrics slack-app to communicate with
123+
the Slack API. The autometrics slack-app will post messages to a specified
124+
channel whenever a alert occurs in your alertmanager (note this requires
125+
modifications in your alertmanager configuration).
126+
background_color: "#00FFAA"
127+
settings:
128+
org_deploy_enabled: false
129+
socket_mode_enabled: false
130+
token_rotation_enabled: false
131+
features:
132+
app_home:
133+
home_tab_enabled: false
134+
messages_tab_enabled: false
135+
bot_user:
136+
display_name: Autometrics
137+
always_online: false
138+
oauth_config:
139+
scopes:
140+
bot:
141+
- chat:write
142+
```
143+
144+
Install your new Slack application into your workspace in the *Install your app* section and grab the *Bot User OAuth Token*, starts with `xoxb-***`
145+
146+
### Deploy the Slack application
147+
148+
You can deploy the Slack application as any other Docker image. The Slack application requires some configuration passed in as environment variables and needs access to the Prometheus, Alertmanager and Slack API.
149+
150+
Here are the necessary environment variables:
151+
152+
| Variable | Description |
153+
| -------- | ----------- |
154+
| `LISTEN_HOST` | Make sure this address allows for remote connections |
155+
| `BASE_URL` | The URL that the Slack should be accessible at (for Slack API) |
156+
| `SLACK_CHANNEL` | Which Slack channel the app should post alerts to (make sure the application is invited to it!) |
157+
| `SLACK_BOT_TOKEN` | The `xoxb-***` value we grabbed earlier when creating the application |
158+
| `STORAGE_DIR` | The directory where the generated alert images should be stored. Make sure it's persistent storage |
159+
| `DB_CONNECTION_STRING` | The sqlite connection string for historic alert storage. Make sure it's persistent |
160+
161+
Here's an example `docker-compose.yaml` file with the above configuration in place:
162+
163+
```yaml filename="docker-compose.yaml"
164+
version: '3.8'
165+
166+
services:
167+
slack-app:
168+
image: autometrics/slack-app:v0.1.0
169+
ports:
170+
- "3031:3031"
171+
environment:
172+
RUST_LOG: info
173+
LOG_JSON: "true"
174+
LISTEN_HOST: 0.0.0.0
175+
PORT: "3031"
176+
BASE_URL: "https://slack-app.example.com"
177+
EXPLORER_URL: https://explorer.autometrics.dev
178+
SLACK_CHANNEL: "test-slack-app"
179+
SLACK_BOT_TOKEN: xoxb-000000000-000000000-000000000
180+
PROMETHEUS_URL: http://prometheus:9090
181+
STORAGE_DIR: /data/
182+
DB_CONNECTION_STRING: "sqlite:///data/slack-app.db?mode=rwc"
183+
volumes:
184+
- slack-app-data:/data
185+
186+
volumes:
187+
slack-app-data:
188+
```
189+
190+
### Update Alertmanager configuration
191+
192+
Finally we need to update the Alertmanager so that it sends a Webhook request whenever an alert is triggered to our newly deployed Slack application:
193+
194+
```yaml filename="alertmanager.yml"
195+
global:
196+
receivers:
197+
- name: default-receiver
198+
webhook_configs:
199+
- send_resolved: true
200+
url: 'http://slack-app:3031/api/alerts'
201+
route:
202+
receiver: default-receiver
203+
```
204+
205+
</Steps>
206+

src/pages/deploying-alertmanager/kubernetes.mdx

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,139 @@ This will install Alertmanager in your cluster along with Prometheus, Node Expor
5050
</Steps>
5151

5252
You can now configure your Alertmanager to group, organize, and send alerts to whichever channel you're using for incident response. See [Alertmanager documentation](https://prometheus.io/docs/alerting/latest/configuration/) for details.
53+
54+
## Add the Autometrics Slack App
55+
56+
Autometrics Slack App is a simple open-source, self-hosted Slack service for Autometrics SLO alerts. It integrates with the Alertmanager and adds more context for each triggered message: the Slack app pulls recent relevant Prometheus data and renders it as an image of the graph on Slack.
57+
58+
Autometrics Slack app is open-source and available as a [Docker image](https://hub.docker.com/r/autometrics/slack-app). Here's a quick guide how to add it and configure it with your Prometheus and Alertmanager setup.
59+
60+
<Steps>
61+
62+
### Create a new Slack application
63+
64+
Go to [https://api.slack.com/apps/](https://api.slack.com/apps/), select your workspace, and create an application **from manifest**.
65+
66+
This is a basic Slack application manifest with limited permissions to post chat messages on channels that the application gets added to. You can find the manifest below:
67+
68+
```yaml filename="manifest.yml"
69+
_metadata:
70+
major_version: 1
71+
minor_version: 0
72+
display_information:
73+
name: Autometrics
74+
description: This bot provides a way for our Autometrics slack-app to communicate with the Slack API.
75+
long_description: |
76+
This bot provides a way for our Autometrics slack-app to communicate with
77+
the Slack API. The autometrics slack-app will post messages to a specified
78+
channel whenever a alert occurs in your alertmanager (note this requires
79+
modifications in your alertmanager configuration).
80+
background_color: "#00FFAA"
81+
settings:
82+
org_deploy_enabled: false
83+
socket_mode_enabled: false
84+
token_rotation_enabled: false
85+
features:
86+
app_home:
87+
home_tab_enabled: false
88+
messages_tab_enabled: false
89+
bot_user:
90+
display_name: Autometrics
91+
always_online: false
92+
oauth_config:
93+
scopes:
94+
bot:
95+
- chat:write
96+
```
97+
98+
Install your new Slack application into your workspace in the *Install your app* section and grab the *Bot User OAuth Token*, starts with `xoxb-***`
99+
100+
### Deploy the Slack application
101+
102+
You can deploy the Slack application as a Kubernetes deployment using the Docker image. The Slack application requires some configuration passed in as environment variables and needs access to the Prometheus, Alertmanager and Slack API.
103+
104+
Here are the necessary environment variables:
105+
106+
| Variable | Description |
107+
| -------- | ----------- |
108+
| `LISTEN_HOST` | Make sure this address allows for remote connections |
109+
| `BASE_URL` | The URL that the Slack should be accessible at (for Slack API) |
110+
| `SLACK_CHANNEL` | Which Slack channel the app should post alerts to (make sure the application is invited to it!) |
111+
| `SLACK_BOT_TOKEN` | The `xoxb-***` value we grabbed earlier when creating the application |
112+
| `STORAGE_DIR` | The directory where the generated alert images should be stored. Make sure it's persistent storage |
113+
| `DB_CONNECTION_STRING` | The sqlite connection string for historic alert storage. Make sure it's persistent |
114+
115+
Here's an example Kubernetes deployment manifest with the above configuration in place:
116+
117+
```yaml filename="deployment.yaml"
118+
---
119+
apiVersion: apps/v1
120+
kind: Deployment
121+
metadata:
122+
name: slack-app
123+
labels:
124+
app: slack-app
125+
spec:
126+
selector:
127+
matchLabels:
128+
app: slack-app
129+
template:
130+
metadata:
131+
labels:
132+
app: slack-app
133+
spec:
134+
containers:
135+
- name: slack-app
136+
image: "autometrics/slack-app:latest"
137+
imagePullPolicy: Always
138+
resources: {}
139+
env:
140+
- name: RUST_LOG
141+
value: "info"
142+
- name: LOG_JSON
143+
value: "true"
144+
- name: LISTEN_HOST
145+
value: 0.0.0.0
146+
- name: PORT
147+
value: "3031"
148+
- name: BASE_URL
149+
value: "https://slack-app.example.com" # NOTE: this url should be accessible to Slack API
150+
- name: EXPLORER_URL
151+
value: https://explorer.autometrics.dev
152+
- name: SLACK_CHANNEL
153+
value: "test-slack-app"
154+
- name: SLACK_BOT_TOKEN
155+
value: xoxb-000000000-000000000-000000000
156+
- name: PROMETHEUS_URL
157+
value: http://prometheus:9090
158+
- name: STORAGE_DIR
159+
value: /data/
160+
- name: DB_CONNECTION_STRING
161+
value: "sqlite:///data/slack-app.db?mode=rwc"
162+
ports:
163+
- containerPort: 3031
164+
volumeMounts:
165+
- name: storage-volume
166+
mountPath: /data
167+
volumes:
168+
- name: storage-volume
169+
persistentVolumeClaim:
170+
claimName: slack-app
171+
```
172+
173+
### Update Alertmanager configuration
174+
175+
Finally we need to update the Alertmanager so that it sends a Webhook request whenever an alert is triggered to our newly deployed Slack application:
176+
177+
```yaml filename="alertmanager.yml"
178+
global:
179+
receivers:
180+
- name: default-receiver
181+
webhook_configs:
182+
- send_resolved: true
183+
url: 'http://slack-app:3031/api/alerts'
184+
route:
185+
receiver: default-receiver
186+
```
187+
188+
</Steps>

0 commit comments

Comments
 (0)