This API communicates with Influx's Kapacitor alerts/monitoring API to enable monitoring and alerting on Akkeris apps based on certain criteria/events. Alerts can be configured for HTTP 5xx status codes, Memory usage, Akkeris Releases, and when an app crashes.
- DATABASE_URL: URL of Postgres database (Required)
- KAPACITOR_URL: URL of Kapacitor instance (Required)
- RUN_MIGRATION: If this variable is present, run the database migration (Optional)
Replace the environment variable values with the correct values for your environment.
export DATABASE_URL="postgres://localhost:5432/kapacitor-alerts-api"
export KAPACITOR_URL="http://localhost:9092"
go run .
To run in Docker:
docker build -t kapacitor-alerts-api .
docker run \
-e "DATABASE_URL=postgres://localhost:5432/kapacitor-alerts-api" \
-e "KAPACITOR_URL=http://localhost:9092" \
-p 8080:8080
--rm \
--name kapacitor-alerts-api \
kapacitor-alerts-api
To run code coverage tests:
export DATABASE_URL="postgres://localhost:5432/kapacitor-alerts-api"
export KAPACITOR_URL="http://localhost:9092"
go test ./...
To import all memory, 5xx, crashed, and alerts tasks already present in Kapacitor, run this with the "RUN_MIGRATION" environment variable present. This will reset the database and import all tasks from Kapacitor.
These are the variables used in the API:
- KAPACITOR_ALERTS_API: URI of the running instance
- APP_NAME: App to act on
- SLACK_CHANNEL: Slack channel to notify
- EMAIL: Email address to notify
- POST: URL to notify via webhook
NOTE: At least one of the notification options must be used (slack, email, post)
Get a list of the configuration of the 5xx event monitoring on all apps
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/5xx
Get the configuration of the 5xx event monitoring on an app
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/task/5xx/{{APP_NAME}}
Get the current state of the 5xx event monitoring on an app
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/task/5xx/{{APP_NAME}}/state
Begin monitoring an app for 5xx events
Endpoint:
Method: POST
URL: {{KAPACITOR_ALERTS_API}}/task/5xx
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"tolerance": "low", // Tolerance (low | medium | high)
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Update the configuration for 5xx monitoring on an app
Endpoint:
Method: PATCH
URL: {{KAPACITOR_ALERTS_API}}/task/5xx
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"tolerance": "medium", // Tolerance (low | medium | high)
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Stop monitoring an app for 5xx events
Endpoint:
Method: DELETE
URL: {{KAPACITOR_ALERTS_API}}/task/5xx/{{APP_NAME}}
Send an alert to a Slack channel, an email address, or as a webhook when an app crashes.
Get a list of the configuration of the crash event monitoring on all apps
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/crashed
Get the configuration of the crash event monitoring on an app
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/task/crashed/{{APP_NAME}}
Begin monitoring an app for crash events
Endpoint:
Method: POST
URL: {{KAPACITOR_ALERTS_API}}/task/crashed
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Update the configuration for crash monitoring on an app
Endpoint:
Method: PATCH
URL: {{KAPACITOR_ALERTS_API}}/task/crashed
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Stop monitoring an app for crash events
Endpoint:
Method: DELETE
URL: {{KAPACITOR_ALERTS_API}}/task/crashed/{{APP_NAME}}
Send an alert to a Slack channel, email address, or as a webhook when an app uses more than the specified amount of memory.
Get the configuration of the release monitoring for all dynos on all apps
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/memory
Get the configuration of the release monitoring for all dynos on an app
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/memory/{{APP_NAME}}
Get the configuration of the memory usage monitoring on an app and dyno
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/memory/{{APP_NAME}}/{{DYNO}}
Begin monitoring an app for memory usage
Endpoint:
Method: POST
URL: {{KAPACITOR_ALERTS_API}}/task/memory
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"dynotype": "web", // Dyno to monitor (use 'all' to monitor all dynos)
"warn": "200", // Warning threshold (in MB)
"crit": "500", // Critical threshold (in MB)
"window": "12h", // Window to use for results
"every": "1m", // How often to check
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Update the configuration for memory usage monitoring on an app
Endpoint:
Method: PATCH
URL: {{KAPACITOR_ALERTS_API}}/task/memory
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"dynotype": "web", // Dyno to monitor (use 'all' to monitor all dynos)
"warn": "500", // Warning threshold (in MB)
"crit": "700", // Critical threshold (in MB)
"window": "12h", // Window to use for results
"every": "1m", // How often to check
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Stop monitoring an app for memory usage
Endpoint:
Method: DELETE
URL: {{KAPACITOR_ALERTS_API}}/task/memory/{{APP_NAME}}/{{DYNO}}
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Send an alert to a Slack channel, email address, or as a webhook when a new version of an app is released.
Get a list of the configuration of all release tasks
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/tasks/release
Get the configuration of the release monitoring on an app
Endpoint:
Method: GET
URL: {{KAPACITOR_ALERTS_API}}/task/release/{{APP_NAME}}
Begin monitoring an app for releases
Endpoint:
Method: POST
URL: {{KAPACITOR_ALERTS_API}}/task/release
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Update the configuration for new release monitoring on an app
Endpoint:
Method: PATCH
URL: {{KAPACITOR_ALERTS_API}}/task/release
Headers:
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Body:
{
"app": "{{APP_NAME}}", // App to monitor
"slack": "{{SLACK_CHANNEL}}", // *Optional* slack channel to notify
"email": "{{EMAIL}}", // *Optional* email address to notify
"post": "{{POST}}" // *Optional* URL to post a webhook to
}
Stop monitoring an app for releases
Endpoint:
Method: DELETE
URL: {{KAPACITOR_ALERTS_API}}/task/release/{{APP_NAME}}