Skip to main content
Like AOF? Give us a star!
If you find AOF useful, please star us on GitHub. It helps us reach more developers and grow the community.

Opsgenie Trigger Platform

The Opsgenie trigger platform enables AOF agents to respond automatically to alert events from Opsgenie's Alert API and webhooks.

Features​

  • ✅ Alert Events: Respond to Create, Acknowledge, Close, Escalate, AddNote, and Custom Actions
  • ✅ Integration Verification: Secure webhook authentication via integration ID
  • ✅ Advanced Filtering: Filter by priority, tags, teams, sources, and actions
  • ✅ Alert Management: Acknowledge, close, add notes, and create alerts via REST API
  • ✅ Rich Metadata: Access comprehensive alert information for informed decisions
  • ✅ Custom Actions: Support for custom alert actions and automation

Quick Start​

1. Create Opsgenie Integration​

  1. Go to Settings → Integrations in Opsgenie
  2. Click Add Integration
  3. Search for Webhook or API Integration
  4. Configure:
    • Name: AOF Alert Handler
    • Webhook URL: https://your-aof-server.com/webhooks/opsgenie
    • Alert Actions: Select actions to forward (Create, AddNote, etc.)
  5. Copy the Integration ID from the integration details

2. Get API Key​

  1. Go to Settings → Integrations → API
  2. Click Create API Key
  3. Configure:
    • Name: AOF Agent
    • Access Rights: Configure & Access or Full Access
  4. Copy the API key

3. Configure Environment Variables​

export OPSGENIE_API_KEY="your-api-key-here"
export OPSGENIE_INTEGRATION_ID="your-integration-id-here" # Optional

4. Create Trigger Resource​

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: opsgenie-alert-handler
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
integration_id: ${OPSGENIE_INTEGRATION_ID}
allowed_actions:
- Create
- AddNote
priority_filter:
- P1
- P2
agent: alert-response-agent
enabled: true

Configuration Reference​

Opsgenie Config​

FieldTypeRequiredDescription
api_urlstring✅ YesOpsgenie API base URL
api_keystring✅ YesAPI key for Opsgenie integration
webhook_tokenstring⬜ OptionalWebhook verification token (legacy)
bot_namestring⬜ OptionalBot name for display (default: "aofbot")
allowed_actionsstring[]⬜ OptionalAlert actions to process (default: all)
priority_filterstring[]⬜ OptionalAllowed priorities (P1-P5)
tag_filterstring[]⬜ OptionalRequired tags (ALL must match)
team_filterstring[]⬜ OptionalAllowed team IDs/names
source_filterstring[]⬜ OptionalAllowed alert sources
integration_idstring⬜ OptionalIntegration ID for verification
verify_with_api_callbackbool⬜ OptionalVerify alerts via API (default: false)
enable_notesbool⬜ OptionalEnable posting notes (default: true)
enable_acknowledgebool⬜ OptionalEnable acknowledging (default: true)
enable_closebool⬜ OptionalEnable closing alerts (default: true)
enable_createbool⬜ OptionalEnable creating alerts (default: true)
rate_limitnumber⬜ OptionalAPI calls per minute (default: 600)
timeout_secsnumber⬜ OptionalHTTP timeout (default: 30)

API URLs by Region​

RegionAPI URL
UShttps://api.opsgenie.com
EUhttps://api.eu.opsgenie.com
On-Premisehttps://opsgenie.yourcompany.com

Supported Alert Actions​

ActionDescription
CreateNew alert created
AcknowledgeAlert acknowledged by responder
CloseAlert closed/resolved
EscalateAlert escalated to next level
AddNoteNote/comment added to alert
CustomActionCustom action executed

Use Cases​

Auto-Diagnose Alerts​

Automatically run diagnostic checks when high-priority alerts are created:

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: auto-diagnose-p1-alerts
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
allowed_actions:
- Create
priority_filter:
- P1
- P2
tag_filter:
- production
agent: diagnostic-agent

Respond to Alert Notes​

Trigger agents when oncall engineers add notes with specific commands:

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: alert-command-handler
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
allowed_actions:
- AddNote
agent: command-processor-agent
filter:
text_contains: "/diagnose"

Source-Based Routing​

Route alerts from different monitoring systems to specialized agents:

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: prometheus-alert-handler
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
source_filter:
- prometheus
- grafana
agent: prometheus-specialist-agent

Team-Specific Automation​

Route alerts to agents based on assigned team:

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: database-team-alerts
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
team_filter:
- database-team
- sre-team
agent: database-automation-agent

Metadata Available to Agents​

When an alert event triggers an agent, the following metadata is available:

FieldDescription
actionAlert action (Create, Acknowledge, Close, etc.)
alert_idOpsgenie alert UUID
tiny_idShort numeric alert ID (for display)
messageAlert title/message
descriptionDetailed alert description
priorityPriority level (P1-P5)
tagsAlert tags (array)
sourceSource system (e.g., "datadog", "prometheus")
entityResource identifier (e.g., "db-prod-01")
aliasDeduplication key
ownerCurrent owner (who acknowledged)
respondersAssigned teams/users (array)
detailsCustom fields (key-value map)

Filtering Examples​

By Priority​

Only process P1 and P2 alerts:

platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
priority_filter:
- P1
- P2

By Tags​

Only process production alerts with critical tag:

platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
tag_filter:
- production
- critical

Note: ALL tags in tag_filter must be present on the alert for it to match.

By Source​

Only process alerts from specific monitoring systems:

platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
source_filter:
- datadog
- prometheus
- cloudwatch

By Team​

Only process alerts assigned to specific teams:

platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
team_filter:
- infrastructure-team
- platform-team

Combined Filters​

Stack multiple filters for precise control:

platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
allowed_actions:
- Create
- AddNote
priority_filter:
- P1
- P2
tag_filter:
- production
source_filter:
- prometheus

Agent Integration​

Example Diagnostic Agent​

apiVersion: aof.sh/v1
kind: Agent
metadata:
name: diagnostic-agent
spec:
llm:
provider: google
model: gemini-2.5-flash

system_prompt: |
You are a diagnostic agent that responds to Opsgenie alerts.

Your workflow:
1. Extract alert metadata (priority, tags, source, entity)
2. Identify the affected service/resource
3. Run relevant diagnostic commands
4. Analyze metrics and logs
5. Generate diagnostic report
6. Add findings as note to Opsgenie alert

Use the alert context provided in the message metadata.

tools:
- kubectl
- prometheus
- elasticsearch

mcp:
- server: kubernetes
enabled: true

Example Command Processor Agent​

apiVersion: aof.sh/v1
kind: Agent
metadata:
name: command-processor-agent
spec:
llm:
provider: google
model: gemini-2.5-flash

system_prompt: |
You are a command processor that responds to commands in Opsgenie alert notes.

Supported commands:
- /diagnose - Run diagnostic checks
- /remediate - Attempt automatic remediation
- /logs [service] - Fetch recent logs
- /metrics [service] - Show key metrics

When you receive an AddNote event:
1. Parse the note text for commands
2. Execute the requested command
3. Add results as a note to the alert

tools:
- kubectl
- prometheus

Example Auto-Remediation Agent​

apiVersion: aof.sh/v1
kind: Agent
metadata:
name: auto-remediation-agent
spec:
llm:
provider: google
model: gemini-2.5-flash

system_prompt: |
You are an auto-remediation agent for common production issues.

When a P1/P2 alert triggers:
1. Identify the issue type from alert details
2. Check if it matches known remediation patterns
3. Execute safe remediation steps
4. Verify the fix worked
5. Add detailed notes about actions taken
6. Acknowledge or close the alert if resolved

Safety rules:
- Only auto-remediate known, safe patterns
- Always add notes before taking action
- Never make destructive changes without human approval

tools:
- kubectl
- aws-cli

mcp:
- server: kubernetes
enabled: true

Security Considerations​

API Key Management​

  • ✅ Store API keys in environment variables or secrets management system
  • ✅ Never commit secrets to version control
  • ✅ Rotate keys periodically
  • ✅ Use integration-specific API keys with minimal permissions
  • ✅ Use different keys for different environments

Integration Verification​

The platform supports two verification methods:

1. Integration ID Verification (Recommended)

config:
integration_id: ${OPSGENIE_INTEGRATION_ID}

Verifies webhook payload contains matching integration ID.

2. API Callback Verification (More Secure, Higher Latency)

config:
verify_with_api_callback: true

Validates alert exists via API call to Opsgenie.

Rate Limiting​

Opsgenie API limits:

  • 600 requests per minute (default)
  • Configure rate_limit to stay within limits
  • AOF automatically respects rate limits

Troubleshooting​

Webhooks Not Triggering​

  1. Verify webhook URL is correct: https://your-server/webhooks/opsgenie
  2. Check integration is active in Opsgenie
  3. Verify alert actions are selected in integration settings
  4. Check AOF logs for parsing errors

Debug Steps:

# Check if webhooks are reaching your server
tail -f /var/log/aof/triggers.log | grep opsgenie

# Verify integration ID
echo $OPSGENIE_INTEGRATION_ID

Integration ID Mismatch​

# Ensure integration ID matches Opsgenie
config:
integration_id: ${OPSGENIE_INTEGRATION_ID}

Check the integration details in Opsgenie to get the correct ID.

Events Being Filtered​

Check your filter configuration is not too restrictive:

# Too many filters? Events might be filtered out
allowed_actions: [Create] # Only Create events
priority_filter: [P1] # Only P1 alerts
tag_filter: [production, critical] # BOTH tags required
source_filter: [datadog] # Only from datadog

Cannot Add Notes to Alerts​

Ensure API key has correct permissions:

# Verify API key is set
echo $OPSGENIE_API_KEY

# Check it's included in config
api_key: ${OPSGENIE_API_KEY}

# Verify enable_notes is true
enable_notes: true

API Rate Limiting​

If hitting rate limits:

config:
rate_limit: 400 # Reduce from default 600
# Or batch operations and reduce frequency

EU Region Configuration​

For EU Opsgenie accounts:

config:
api_url: https://api.eu.opsgenie.com
api_key: ${OPSGENIE_API_KEY}

Platform Capabilities​

FeatureSupported
Threading✅ Yes (all alert actions grouped by alert ID)
Interactive Elements✅ Yes (custom actions)
File Attachments❌ No
Reactions❌ No
Rich Text✅ Yes (markdown in notes)

API Reference​

Add Note to Alert​

platform.add_note(
alert_id: &str,
note: &str,
).await

Acknowledge Alert​

platform.acknowledge_alert(
alert_id: &str,
note: Option<&str>,
).await

Close Alert​

platform.close_alert(
alert_id: &str,
note: Option<&str>,
).await

Create Alert​

platform.create_alert(
message: &str,
description: Option<&str>,
priority: Option<&str>,
tags: Vec<String>,
details: HashMap<String, String>,
).await

Advanced Configuration​

Custom Action Handlers​

Handle custom actions defined in Opsgenie:

apiVersion: aof.sh/v1
kind: Trigger
metadata:
name: custom-action-handler
spec:
platform:
type: opsgenie
config:
api_url: https://api.opsgenie.com
api_key: ${OPSGENIE_API_KEY}
allowed_actions:
- CustomAction
agent: custom-action-agent

Disable Specific Features​

Control what the agent can do:

config:
enable_notes: true # Allow adding notes
enable_acknowledge: false # Prevent acknowledging
enable_close: false # Prevent closing
enable_create: true # Allow creating new alerts

Alert Details as Context​

Access custom fields in agent prompts:

spec:
agent: diagnostic-agent
parameters:
# Custom fields from alert.details are available in metadata
use_runbook_url: "{{ metadata.details.runbook_url }}"
affected_region: "{{ metadata.details.region }}"

Examples​

See complete examples in /docs/examples/triggers/:

  • opsgenie-alert-response.yaml - Full alert response workflow
  • opsgenie-auto-remediation.yaml - Automated remediation
  • opsgenie-command-processor.yaml - Command handling from notes