πŸ”§ DevOps

OpsGenie

An alerting and on-call management service

πŸ“– Detailed Explanation

OpsGenie is an incident management and on-call management platform acquired by Atlassian. It centrally manages alerts generated by monitoring tools, routes them to the appropriate responders, and propagates alerts according to escalation policies. It structures the incident response workflows of SRE and DevOps teams.

OpsGenie's core features are alert management, on-call scheduling, and escalation policies. It integrates with more than 200 tools, including Prometheus, Datadog, and CloudWatch, to receive alerts, groups duplicate alerts, and notifies on-call responders by SMS, phone call, and app push notification.

An on-call schedule defines the rotation in which team members take turns handling incident response. It distinguishes between day/night and weekdays/weekends, and also manages vacations and overrides. If the primary responder does not respond, the alert is automatically escalated to the secondary responder, preventing missed alerts.

OpsGenie integrates with Jira Service Management to automatically create incident tickets from alerts, and supports timeline recording and postmortem writing. Similar tools include PagerDuty, Incident.io, and Rootly, and OpsGenie's strength is its integration with the Atlassian ecosystem (Jira, Confluence, Statuspage).

πŸ’» Code Example

# Prometheus Alertmanager -> OpsGenie 연동
# alertmanager.yml
global:
  resolve_timeout: 5m

route:
  receiver: 'opsgenie-critical'
  group_by: ['alertname', 'service']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  routes:
    # Critical μ•Œλ¦Όμ€ μ¦‰μ‹œ 전솑
    - match:
        severity: critical
      receiver: 'opsgenie-critical'
      continue: true
    # Warning은 μ—…λ¬΄μ‹œκ°„μ—λ§Œ
    - match:
        severity: warning
      receiver: 'opsgenie-warning'
      active_time_intervals:
        - business_hours

receivers:
  - name: 'opsgenie-critical'
    opsgenie_configs:
      - api_key: ''
        message: '{{ .GroupLabels.alertname }}: {{ .CommonAnnotations.summary }}'
        description: '{{ .CommonAnnotations.description }}'
        priority: 'P1'
        tags: 'prometheus,{{ .GroupLabels.service }}'
        # μ•Œλ¦Ό λΌμš°νŒ…
        responders:
          - type: team
            name: 'platform-oncall'
        # μΆ”κ°€ 상세 정보
        details:
          environment: '{{ .GroupLabels.environment }}'
          runbook: '{{ .CommonAnnotations.runbook_url }}'

  - name: 'opsgenie-warning'
    opsgenie_configs:
      - api_key: ''
        priority: 'P3'
        responders:
          - type: team
            name: 'platform-team'
# OpsGenie APIλ₯Ό ν†΅ν•œ μ•Œλ¦Ό 생성 및 관리
import requests

OPSGENIE_API_KEY = "your-api-key"
BASE_URL = "https://api.opsgenie.com/v2"

headers = {
    "Authorization": f"GenieKey {OPSGENIE_API_KEY}",
    "Content-Type": "application/json"
}

# μ•Œλ¦Ό 생성
def create_alert(message: str, priority: str = "P3", **kwargs):
    payload = {
        "message": message,
        "priority": priority,
        "tags": kwargs.get("tags", []),
        "details": kwargs.get("details", {}),
        "responders": [
            {"type": "team", "name": "platform-oncall"}
        ]
    }
    response = requests.post(
        f"{BASE_URL}/alerts",
        headers=headers,
        json=payload
    )
    return response.json()

# μ•Œλ¦Ό λ‹«κΈ°
def close_alert(alert_id: str, note: str = "Issue resolved"):
    payload = {"note": note}
    response = requests.post(
        f"{BASE_URL}/alerts/{alert_id}/close",
        headers=headers,
        json=payload
    )
    return response.json()

# 온콜 λ‹΄λ‹Ήμž 쑰회
def get_on_call(schedule_name: str):
    response = requests.get(
        f"{BASE_URL}/schedules/{schedule_name}/on-calls",
        headers=headers
    )
    on_calls = response.json().get("data", {}).get("onCallParticipants", [])
    return [p["name"] for p in on_calls]

# μ‚¬μš© μ˜ˆμ‹œ
create_alert(
    message="Database connection pool exhausted",
    priority="P1",
    tags=["database", "production"],
    details={
        "service": "order-api",
        "pod": "order-api-abc123",
        "runbook": "https://wiki/runbooks/db-pool-exhausted"
    }
)

πŸ—£οΈ How It's Said in Practice

SRE: "During the last outage, nobody responded for 30 minutes. They said the on-call person had their phone on silent..."

Junior: "How about setting up the escalation policy to be faster?"

Senior: "Let's change it so P1 escalates after 5 minutes and notifies the whole team after 10 minutes. And let's also set it up so that if they don't receive the OpsGenie app notification, it goes through to a phone call."

Interviewer: "Please tell me about your on-call experience and incident management process."

Candidate: "I was on call once every two weeks, and I received alerts through OpsGenie. P1 alerts came in simultaneously via app push and phone call, and if I didn't ACK within 5 minutes, they were escalated to the backup responder. Every alert had a Runbook link, so I could follow the response procedure, and after an incident, a Jira ticket was automatically created and I wrote the postmortem."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

Reviewer: "Please add a runbook URL to this alert configuration. If there is a runbook field in the OpsGenie details, the responder can immediately see the response document."

Author: "I'll add runbook_url as an annotation in the alert template and map it to the OpsGenie details."

⚠️ Cautions

πŸ“š Learn More