-
Notifications
You must be signed in to change notification settings - Fork 2
4. Alerts
Vincenzo Reina edited this page Apr 21, 2025
·
10 revisions
ServerPulse includes a robust alert system that can notify you about important server events through Discord. This guide covers setting up and customizing alerts.
- Open your Discord server settings
- Navigate to "Integrations" → "Webhooks"
- Click "Create Webhook"
- Choose a name and channel for alerts
- Copy the webhook URL
- Open
infra/grafana/provisioning/alerting/discord_contact.yml
- Replace the example webhook URL with yours:
apiVersion: 1
contactPoints:
- orgId: 1
name: Discord contact point
receivers:
- uid: deiz0m4w2afpcb
type: discord
settings:
url: https://discord.com/api/webhooks/your-webhook # Replace this
message: '{{ template "discord.default.message" . }}'
title: '{{ template "default.title" . }}'
- Restart Docker containers to apply changes:
docker compose down
docker compose up -d
ServerPulse comes with pre-configured alerts:
# From metrics.yml
condition: C
data:
- refId: A
datasourceUid: P5697886F9CA74929
model:
query: "from(bucket: \"metrics_db\")
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r._measurement == \"minecraft_stats\")
|> filter(fn: (r) => r._field == \"tps_1m\")
|> filter(fn: (r) => r.server == \"bed1\")"
- Triggers when TPS drops below 18
- Evaluates every 10 seconds
- Includes 5-minute historical context
Edit infra/grafana/provisioning/alerting/contact_policy.yml
:
apiVersion: 1
policies:
- orgId: 1
receiver: Discord contact point
group_wait: 0s # Initial wait before first alert
group_interval: 30s # Wait between alert groups
repeat_interval: 3m # Time before resending same alert
To add new alerts, you'll need to create or modify files in the infra/grafana/provisioning/alerting/
directory.
- Create a new file (e.g.,
infra/grafana/provisioning/alerting/custom_alerts.yml
):
apiVersion: 1
groups:
- orgId: 1
name: Custom Alerts
folder: Metrics alerts
interval: 10s
rules:
- uid: memory_alert # Unique identifier
title: High Memory Usage
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: P5697886F9CA74929
model:
query: |
from(bucket: "metrics_db")
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r._measurement == "minecraft_stats")
|> filter(fn: (r) => r._field == "used_memory")
notification_settings:
receiver: Discord contact point
- Or modify the existing
metrics.yml
file in the same directory:
apiVersion: 1
groups:
- orgId: 1
name: Metrics evaluation
folder: Metrics alerts
interval: 10s
rules:
# Existing TPS alert here
- uid: memory_alert # Add new alert
title: High Memory Usage
# ... rest of alert configuration
After adding new alert files or modifying existing ones:
- Restart the Docker containers:
docker compose down
docker compose up -d
- Check Grafana's alert list to verify your new alerts appear
-
Simulate low TPS:
- Use a plugin or command to stress test the server
- Wait for alert notification (should arrive within 30s)
-
Verify Discord Integration:
- Check Discord channel for alert messages
- Confirm formatting and content