Skip to content

4. Alerts

Vincenzo Reina edited this page Apr 21, 2025 · 9 revisions

Alert System

ServerPulse includes a robust alert system that can notify you about important server events through Discord. This guide covers setting up and customizing alerts.

Discord Integration Setup

Creating a Discord Webhook

  1. Open your Discord server settings
  2. Navigate to "Integrations" → "Webhooks"
  3. Click "Create Webhook"
  4. Choose a name and channel for alerts
  5. Copy the webhook URL

Configuring Discord Integration

  1. Open infra/grafana/provisioning/alerting/discord_contact.yml
  2. 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" . }}'
  1. Restart Docker containers to apply changes:
docker compose down
docker compose up -d

Default Alert Rules

ServerPulse comes with pre-configured alerts:

TPS Monitoring

# 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

Customizing Alerts

Alert Timing

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

Creating New Alert Rules

  1. Memory Usage Alert Example:
groups:
  - name: Memory Alerts
    rules:
      - title: High Memory Usage
        condition: when used_memory > 80% of committed_memory
        data:
          # InfluxDB query for memory metrics
          query: from(bucket: "metrics_db")
            |> filter(fn: (r) => r._field == "used_memory")
  1. Player Count Alert Example:
groups:
  - name: Player Alerts
    rules:
      - title: High Player Count
        condition: when players_online > 50
        data:
          # InfluxDB query for player count
          query: from(bucket: "metrics_db")
            |> filter(fn: (r) => r._field == "players_online")

Testing Alerts

  1. Simulate low TPS:

    • Use a plugin or command to stress test the server
    • Wait for alert notification (should arrive within 30s)
  2. Verify Discord Integration:

    • Check Discord channel for alert messages
    • Confirm formatting and content

Related Pages

Clone this wiki locally