Skip to content

Commit f84045b

Browse files
authored
Merge pull request #26 from VersusControl/docs/update
(docs): add advanced template tips
2 parents f416051 + 7a69a65 commit f84045b

File tree

3 files changed

+243
-189
lines changed

3 files changed

+243
-189
lines changed

README.md

Lines changed: 109 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ An open-source incident management system with multi-channel alerting capabiliti
1414
- [Installation](#installation)
1515
- [Configuration](#configuration)
1616
- [Environment Variables](#environment-variables)
17-
- [Custom Alert Templates](#custom-alert-templates)
1817
- [Development](#development)
1918
- [Docker](#docker)
2019
- [Kubernetes](#kubernetes)
21-
- [API Usage](#api-usage)
2220
- [Advanced API Usage](#advanced-api-usage)
2321
- [SNS Usage](#sns-usage)
2422
- [Example](#example)
@@ -46,7 +44,7 @@ An open-source incident management system with multi-channel alerting capabiliti
4644
- Docker 20.10+ (optional)
4745
- Slack workspace (for Slack notifications)
4846

49-
### Installation
47+
### Easy Installation with Docker
5048

5149
```bash
5250
docker run -p 3000:3000 \
@@ -56,7 +54,7 @@ docker run -p 3000:3000 \
5654
ghcr.io/versuscontrol/versus-incident
5755
```
5856

59-
### Build from source
57+
### Or Build from source
6058

6159
```bash
6260
# Clone the repository
@@ -78,17 +76,6 @@ export SLACK_CHANNEL_ID=your_channel
7876
./versus-incident
7977
```
8078

81-
Or run with Docker:
82-
```
83-
docker build -t versus-incident .
84-
85-
docker run -p 3000:3000 \
86-
-e SLACK_ENABLE=true \
87-
-e SLACK_TOKEN=your_token \
88-
-e SLACK_CHANNEL_ID=your_channel \
89-
versus-incident
90-
```
91-
9279
## Configuration
9380

9481
A sample configuration file is located at `config/config.yaml`:
@@ -125,6 +112,7 @@ alert:
125112

126113
queue:
127114
enable: true
115+
debug_body: true
128116

129117
# AWS SNS
130118
sns:
@@ -178,98 +166,147 @@ The application relies on several environment variables to configure alerting se
178166

179167
Ensure these environment variables are properly set before running the application. You can configure them in your `.env` file, Docker environment variables, or Kubernetes secrets.
180168

181-
## Custom Alert Templates
169+
## Development
182170

183-
### Slack Template
184-
Create your Slack message template, for example `config/slack_message.tmpl`:
171+
### Docker
185172

173+
#### Basic Deployment
174+
175+
```bash
176+
docker run -d \
177+
-p 3000:3000 \
178+
-e SLACK_ENABLE=true \
179+
-e SLACK_TOKEN=your_slack_token \
180+
-e SLACK_CHANNEL_ID=your_channel_id \
181+
--name versus \
182+
ghcr.io/versuscontrol/versus-incident
186183
```
187-
*Critical Error in {{.ServiceName}}*
188-
----------
189-
Error Details:
190-
{{.Logs}}
191-
----------
192-
Owner <@{{.UserID}}> please investigate
193-
```
194-
### Telegram Template
195184

196-
For Telegram, you can use HTML formatting. Create your Telegram message template, for example `config/telegram_message.tmpl`:
185+
#### With Custom Templates
186+
187+
Create a configuration file:
188+
197189
```
198-
🚨 <b>Critical Error Detected!</b> 🚨
199-
📌 <b>Service:</b> {{.ServiceName}}
200-
⚠️ <b>Error Details:</b>
201-
{{.Logs}}
190+
mkdir -p ./config && touch config.yaml
202191
```
203-
This template will be parsed with HTML tags when sending the alert to Telegram.
204192

205-
### Email Template
206-
Create your email message template, for example `config/email_message.tmpl`:
193+
`config.yaml`:
194+
```yaml
195+
name: versus
196+
host: 0.0.0.0
197+
port: 3000
198+
199+
alert:
200+
slack:
201+
enable: true
202+
token: ${SLACK_TOKEN}
203+
channel_id: ${SLACK_CHANNEL_ID}
204+
template_path: "/app/config/slack_message.tmpl"
207205

206+
telegram:
207+
enable: false
208208
```
209-
Subject: Critical Error Alert - {{.ServiceName}}
210209
211-
Critical Error Detected in {{.ServiceName}}
212-
----------------------------------------
210+
**Configuration Notes**
213211
214-
Error Details:
215-
{{.Logs}}
212+
Ensure `template_path` in `config.yaml` matches container path:
213+
```yaml
214+
alert:
215+
slack:
216+
template_path: "/app/config/slack_message.tmpl" # For containerized env
217+
```
216218

217-
Please investigate this issue immediately.
219+
**Slack Template**
220+
221+
Create your Slack message template, for example `config/slack_message.tmpl`:
218222

219-
Best regards,
220-
Versus Incident Management System
221223
```
222-
This template supports both plain text and HTML formatting for email notifications.
224+
🔥 *Critical Error in {{.ServiceName}}*
223225
224-
## Development
226+
❌ Error Details:
227+
```{{.Logs}}```
225228

226-
### Docker
229+
Owner <@{{.UserID}}> please investigate
230+
```
231+
232+
**Run with volume mount:**
227233

228-
#### Basic Deployment
229234
```bash
230235
docker run -d \
231236
-p 3000:3000 \
237+
-v $(pwd)/config:/app/config \
232238
-e SLACK_ENABLE=true \
233239
-e SLACK_TOKEN=your_slack_token \
234240
-e SLACK_CHANNEL_ID=your_channel_id \
235241
--name versus \
236242
ghcr.io/versuscontrol/versus-incident
237243
```
238244

239-
#### With Custom Templates
245+
Verify template mounting:
240246

241-
**Configuration Notes**
242-
- Ensure `template_path` in config.yaml matches container path:
243-
```yaml
244-
alert:
245-
slack:
246-
template_path: "/app/config/slack_message.tmpl" # For containerized env
247-
```
248-
- File permissions: Templates must be readable by the app user (UID 1000 in Dockerfile)
249-
250-
1. Create local config directory with your templates:
251247
```bash
252-
mkdir -p ./config
253-
cp your-custom-template.tmpl ./config/slack_message.tmpl
248+
docker exec versus ls -l /app/config
254249
```
255250

256-
2. Run with volume mount:
251+
To test, simply send an incident to Versus:
252+
257253
```bash
258-
docker run -d \
259-
-p 3000:3000 \
260-
-v $(pwd)/config:/app/config \
261-
-e SLACK_ENABLE=true \
262-
-e SLACK_TOKEN=your_slack_token \
263-
-e SLACK_CHANNEL_ID=your_channel_id \
264-
--name versus \
265-
ghcr.io/versuscontrol/versus-incident
254+
curl -X POST http://localhost:3000/api/incidents \
255+
-H "Content-Type: application/json" \
256+
-d '{
257+
"Logs": "[ERROR] This is an error log from User Service that we can obtain using Fluent Bit.",
258+
"ServiceName": "order-service",
259+
"UserID": "SLACK_USER_ID"
260+
}'
266261
```
267262

268-
3. Verify template mounting:
269-
```bash
270-
docker exec versus ls -l /app/config
263+
Response:
264+
265+
```json
266+
{
267+
"status":"Incident created"
268+
}
269+
```
270+
271+
**Result:**
272+
273+
![Slack Alert](src/docs/images/versus-result.png)
274+
275+
#### Other Templates
276+
277+
**Telegram Template**
278+
279+
For Telegram, you can use HTML formatting. Create your Telegram message template, for example `config/telegram_message.tmpl`:
280+
```
281+
🚨 <b>Critical Error Detected!</b> 🚨
282+
📌 <b>Service:</b> {{.ServiceName}}
283+
⚠️ <b>Error Details:</b>
284+
{{.Logs}}
271285
```
272286

287+
This template will be parsed with HTML tags when sending the alert to Telegram.
288+
289+
**Email Template**
290+
291+
Create your email message template, for example `config/email_message.tmpl`:
292+
293+
```
294+
Subject: Critical Error Alert - {{.ServiceName}}
295+
296+
Critical Error Detected in {{.ServiceName}}
297+
----------------------------------------
298+
299+
Error Details:
300+
{{.Logs}}
301+
302+
Please investigate this issue immediately.
303+
304+
Best regards,
305+
Versus Incident Management System
306+
```
307+
308+
This template supports both plain text and HTML formatting for email notifications.
309+
273310
### Kubernetes
274311

275312
1. Create a secret for Slack:
@@ -380,7 +417,7 @@ spec:
380417
targetPort: 3000
381418
```
382419
383-
4. Apply changes:
420+
4. Apply:
384421
```bash
385422
kubectl apply -f versus-deployment.yaml
386423
```
@@ -390,27 +427,6 @@ kubectl apply -f versus-deployment.yaml
390427
kubectl exec -it <pod-name> -- ls -l /app/config
391428
```
392429

393-
## API Usage
394-
395-
Create an incident:
396-
397-
```bash
398-
curl -X POST http://localhost:3000/api/incidents \
399-
-H "Content-Type: application/json" \
400-
-d '{
401-
"Logs": "[ERROR] This is an error log from User Service that we can obtain using Fluent Bit.",
402-
"ServiceName": "order-service",
403-
"UserID": "SLACK_USER_ID"
404-
}'
405-
```
406-
407-
**Response:**
408-
```json
409-
{
410-
"status":"Incident created"
411-
}
412-
```
413-
414430
## Advanced API Usage
415431
We provide a way to overwrite configuration values using query parameters, allowing you to send alerts to different channel IDs based on the service.
416432

src/advanced-template-tips.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ Handle multiple alerts in one template:
1717
🔗 *Details*: {{.detail | toJson}}
1818
```
1919

20+
If the field does not exist when passed to the template, let's use the template's `printf` function to handle it.
21+
22+
```
23+
{{ if contains (printf "%v" .source) "aws.glue" }}
24+
🔥 *Glue Job Failed*: {{.detail.jobName}}
25+
26+
❌ Error:
27+
```{{.detail.errorMessage}}```
28+
{{ else }}
29+
🔥 *Critical Error in {{.ServiceName}}*
30+
31+
❌ Error Details:
32+
```{{.Logs}}```
33+
34+
Owner <@{{.UserID}}> please investigate
35+
{{ end }}
36+
```
37+
2038
### Conditional Formatting
2139

2240
Highlight critical issues:

0 commit comments

Comments
 (0)