Send Alerts to Opsgenie

Configure Edge Delta to create Opsgenie alerts using the Alert API for on-call management and incident response.

Overview

This guide demonstrates how to create Opsgenie alerts from EdgeDelta using the Alert API. Opsgenie is an incident management platform that routes alerts to the right on-call responders and enables effective incident response.

Prerequisites

  1. Opsgenie Account: Access to create API integrations
  2. API Key: A GenieKey from an Opsgenie integration
  3. EdgeDelta Pipeline: A configured threshold node or monitor generating signals

Pipeline Flow

flowchart LR classDef icon-metrics fill:#E7EEFC,stroke:#2563EB,color:#0F2169; classDef icon-alert fill:#FDEAD7,stroke:#EA580C,color:#7C2D12; classDef icon-destination fill:#FCEADB,stroke:#EA580C,color:#7C2D12; classDef icon-notify fill:#FCE7E7,stroke:#DC2626,color:#7C1D1D; Metrics["<span class='ph ph-chart-line-up'></span> Metric Source"] Threshold["<span class='ph ph-funnel'></span> Threshold Node"] Webhook["<span class='ph ph-paper-plane-tilt'></span> Webhook Destination"] Opsgenie["<span class='ph ph-bell-ringing'></span> Opsgenie"] Metrics --> Threshold Threshold --> Webhook Webhook --> Opsgenie class Metrics icon-metrics; class Threshold icon-alert; class Webhook icon-destination; class Opsgenie icon-notify;

Configuration

Step 1: Create an Opsgenie API Integration

  1. Log in to your Opsgenie account
  2. Navigate to SettingsIntegration List
  3. Search for API and select it
  4. Click Add
  5. Configure the integration name and team assignment
  6. Copy the API Key (GenieKey)
  7. Save the integration

Step 2: Store the API Key

Store the API key as an environment variable:

export OPSGENIE_API_KEY="your-opsgenie-api-key"

Step 3: Configure the Webhook Node

Create a webhook node that sends alerts to Opsgenie:

- name: opsgenie_alerts
  type: webhook_output
  endpoint: https://api.opsgenie.com/v2/alerts
  headers:
  - header: Content-Type
    value: "application/json"
  - header: Authorization
    value: "GenieKey ${OPSGENIE_API_KEY}"
  suppression_window: 20m
  payload: |
    {
      "message": "{{ .item.signal.title }}",
      "alias": "{{ .item.signal.signal_id }}",
      "description": "{{ .item.signal.description }}\n\nHost: {{ index .item.resource \"host.name\" }}\nSource: {{ index .item.resource \"ed.source_name\" }}\nValue: {{ .item.signal.value }}\nThreshold: {{ .item.signal.threshold_value }}",
      "tags": [
        "EdgeDelta",
        "{{ index .item.resource \"ed.source_type\" }}",
        "{{ index .item.resource \"host.name\" }}"
      ],
      "details": {
        "signal_id": "{{ .item.signal.signal_id }}",
        "metric_name": "{{ .item.signal.name }}",
        "current_value": "{{ .item.signal.value }}",
        "threshold": "{{ .item.signal.threshold_value }}",
        "threshold_type": "{{ .item.signal.threshold_type }}",
        "host": "{{ index .item.resource \"host.name\" }}",
        "source_name": "{{ index .item.resource \"ed.source_name\" }}",
        "source_type": "{{ index .item.resource \"ed.source_type\" }}",
        "agent_tag": "{{ index .item.resource \"ed.tag\" }}",
        "timestamp": "{{ .item.timestamp }}"
      },
      "priority": "P2"
    }    

Step 4: Connect to a Threshold Node

nodes:
  - name: memory_threshold
    type: threshold
    filter: item.name == "system.memory.usage"
    condition: value > 85

  - name: opsgenie_alerts
    type: webhook_output
    # ... configuration from above ...

links:
  - from: memory_threshold
    to: opsgenie_alerts

Alert API Payload Reference

Required Fields

FieldDescriptionExample
messageAlert title (max 130 chars){{ .item.signal.title }}
FieldDescriptionUsage
aliasUnique identifier for deduplicationSignal ID
descriptionDetailed information (max 15000 chars)Alert details and context
priorityAlert priority: P1 to P5P2 for standard alerts

Optional Fields

FieldDescriptionUsage
respondersTeams, users, or escalations to notifyTeam assignment
visibleToTeams/users who can see the alertAccess control
actionsCustom actions for the alert["Restart Service", "Check Logs"]
tagsLabels for categorization["EdgeDelta", "production"]
detailsCustom key-value propertiesMetric details
entityDomain/entity the alert relates toService name
sourceSource of the alertEdgeDelta
noteAdditional note for the alertContext for responders

Dynamic Priority Mapping

Map priority based on metric severity:

payload: |
  {
    "message": "{{ .item.signal.title }}",
    "alias": "{{ .item.signal.signal_id }}",
    "priority": "{{ if gt .item.signal.value (mul .item.signal.threshold_value 3) }}P1{{ else if gt .item.signal.value (mul .item.signal.threshold_value 2) }}P2{{ else if gt .item.signal.value .item.signal.threshold_value }}P3{{ else }}P4{{ end }}",
    ...
  }  

Priority mapping:

  • P1: Critical - value exceeds 3x threshold
  • P2: High - value exceeds 2x threshold
  • P3: Moderate - value exceeds threshold
  • P4: Low - informational

Routing to Specific Teams

Route alerts to specific responders based on source:

payload: |
  {
    "message": "{{ .item.signal.title }}",
    "responders": [
      {
        "type": "team",
        "name": "{{ if contains (index .item.resource \"ed.source_name\") \"database\" }}Database Team{{ else }}Infrastructure Team{{ end }}"
      }
    ],
    ...
  }  

Or use static team assignments:

payload: |
  {
    "responders": [
      {"type": "team", "name": "Infrastructure"},
      {"type": "user", "username": "oncall@company.com"}
    ],
    ...
  }  

Adding Custom Actions

Include action buttons in the Opsgenie alert:

payload: |
  {
    "message": "{{ .item.signal.title }}",
    "actions": [
      "View in EdgeDelta",
      "Restart Service",
      "Acknowledge",
      "Add Note"
    ],
    ...
  }  

Auto-Close Alerts

Create a separate webhook to close alerts when metrics return to normal:

- name: opsgenie_close
  type: webhook_output
  endpoint: https://api.opsgenie.com/v2/alerts/{{ .item.signal.signal_id }}/close?identifierType=alias
  headers:
  - header: Content-Type
    value: "application/json"
  - header: Authorization
    value: "GenieKey ${OPSGENIE_API_KEY}"
  payload: |
    {
      "note": "Alert auto-closed by EdgeDelta at {{ .item.timestamp }}. Metric returned to normal."
    }    

Note: The alias must match the original alert’s alias for the close operation to work.

EU Region Configuration

If your Opsgenie account is in the EU region, use the EU endpoint:

endpoint: https://api.eu.opsgenie.com/v2/alerts

Testing

Test with Opsgenie’s API Console

  1. Go to SettingsIntegration List → Your API integration
  2. Use the Test section to verify connectivity
  3. Check the Logs tab for request/response details

Test with a Local Endpoint

Verify your payload structure before connecting to Opsgenie:

endpoint: http://localhost:8080/webhook-test

Expected Response

Successful alert creation returns:

{
  "result": "Request will be processed",
  "took": 0.302,
  "requestId": "43a29c5c-3dbf-4fa4-9c26-f4f71023e120"
}

Troubleshooting

IssueSolution
401 UnauthorizedVerify GenieKey and Authorization header format
403 ForbiddenCheck API integration permissions
422 Unprocessable EntityValidate payload fields and character limits
Duplicate alertsUse consistent alias values
Alerts not auto-closingVerify alias matches and endpoint format

Character Limits

  • message: 130 characters max
  • alias: 512 characters max
  • description: 15000 characters max
  • tags: 20 tags max, 50 characters each

Best Practices

  1. Use aliases for deduplication: Prevent duplicate alerts with consistent signal IDs
  2. Set appropriate priorities: Reserve P1 for genuine critical issues
  3. Include context in details: Custom details help responders investigate faster
  4. Tag consistently: Use tags for filtering and reporting
  5. Configure suppression windows: 20-30 minutes works well for most alerts
  6. Route to the right teams: Use responders to ensure proper escalation
  7. Test in non-production first: Validate payloads before production deployment

See Also