{"id":8058,"library":"dagster-pagerduty","title":"Dagster PagerDuty","description":"Dagster PagerDuty is a library that provides an integration between Dagster, a data orchestration platform, and PagerDuty, a SaaS incident response platform. It enables users to programmatically create alerts from their Dagster code by wrapping PagerDuty's Events API V2. Currently at version 0.29.0, this library is part of the larger Dagster monorepo, with its versioning for libraries like dagster-pagerduty aligning with the main dagster core releases (e.g., core 1.13.0 corresponds to libraries 0.29.0).","status":"active","version":"0.29.0","language":"en","source_language":"en","source_url":"https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-pagerduty","tags":["dagster","pagerduty","observability","alerting","etl","data-orchestration"],"install":[{"cmd":"pip install dagster-pagerduty","lang":"bash","label":"Install dagster-pagerduty"}],"dependencies":[{"reason":"Core Dagster library is required as dagster-pagerduty is an integration package. This library requires Python >=3.10, <3.15.","package":"dagster"}],"imports":[{"note":"`pagerduty_resource` is a legacy resource definition. `PagerDutyService` is the recommended Pythonic resource for newer Dagster versions.","wrong":"from dagster_pagerduty import pagerduty_resource","symbol":"PagerDutyService","correct":"from dagster_pagerduty import PagerDutyService"},{"note":"Standard alias for the core Dagster library.","symbol":"dagster","correct":"import dagster as dg"}],"quickstart":{"code":"import dagster as dg\nfrom dagster_pagerduty import PagerDutyService\nimport os\n\n@dg.asset\ndef critical_data_check(pagerduty: PagerDutyService):\n    # Simulate a check that might fail\n    if os.environ.get('SIMULATE_FAILURE') == 'true':\n        summary_message = \"Critical data check failed!\"\n        pagerduty.EventV2_create(\n            summary=summary_message,\n            source=\"data_pipeline_monitor\",\n            severity=\"critical\",\n            event_action=\"trigger\",\n            details={\n                \"run_url\": \"https://dagster.example.com/runs/abc123\",\n                \"error_message\": \"Data quality threshold breached.\"\n            }\n        )\n        raise Exception(summary_message)\n    else:\n        print(\"Critical data check passed.\")\n\ndefs = dg.Definitions(\n    assets=[critical_data_check],\n    resources={\n        \"pagerduty\": PagerDutyService(routing_key=os.environ.get('PAGERDUTY_ROUTING_KEY', ''))\n    },\n)\n\n# To run locally (ensure PAGERDUTY_ROUTING_KEY is set in your environment):\n# from dagster import materialize_to_memory\n# import os\n# os.environ['PAGERDUTY_ROUTING_KEY'] = 'your_pagerduty_integration_key'\n# # Set SIMULATE_FAILURE to 'true' to trigger an alert\n# # os.environ['SIMULATE_FAILURE'] = 'true'\n# result = materialize_to_memory(defs.get_assets_def_for_asset_keys([\"critical_data_check\"]), resources=defs.resources)\n# assert result.success # Will fail if SIMULATE_FAILURE is 'true' and exception is raised\n","lang":"python","description":"This quickstart demonstrates how to define a `PagerDutyService` resource and use it within a Dagster asset to trigger a PagerDuty alert. The `routing_key` (PagerDuty Events API V2 integration key) should be securely provided, typically via an environment variable. When the `critical_data_check` asset encounters a simulated failure, it sends a 'critical' event to PagerDuty."},"warnings":[{"fix":"Replace usages of `@resource` decorated functions like `pagerduty_resource` with `PagerDutyService(routing_key=...)` directly in your `Definitions` or as a `ConfigurableResource` subclass.","message":"The `pagerduty_resource` function is considered legacy. Users should migrate to `PagerDutyService` class-based resource definitions for improved type hinting and Pydantic-backed configuration, especially with Dagster 1.3+ and newer.","severity":"deprecated","affected_versions":"Dagster 1.3.0 and newer (dagster-pagerduty 0.27.0 and newer)"},{"fix":"Ensure you have created an Events API V2 integration in your PagerDuty service and obtained the 'Integration Key' (routing key). Pass this key to the `routing_key` parameter of `PagerDutyService`.","message":"PagerDuty alerts require a valid Events API V2 integration key (routing key). This key must be configured correctly in PagerDuty for a specific service, and then provided to the `PagerDutyService` resource. An incorrect or missing key will result in API errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify your PagerDuty service's escalation policies, on-call schedules, and suppression rules. Ensure there is an active on-call responder for the service receiving the alerts from Dagster.","message":"Alerts triggered via `dagster-pagerduty` rely on the PagerDuty API. If PagerDuty itself is not configured to send notifications (e.g., no one is on call for the affected service, or suppression rules are active), the alert may be triggered in PagerDuty but not result in an actual notification.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install dagster-pagerduty`.","cause":"The `dagster-pagerduty` library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'dagster_pagerduty'"},{"fix":"Double-check that the `routing_key` provided to `PagerDutyService` is correct and active for an Events API V2 integration in PagerDuty. Review the `summary`, `source`, `severity`, and `event_action` parameters to ensure they conform to PagerDuty's Events API V2 specification.","cause":"This typically indicates an issue with the PagerDuty routing key or the structure of the event payload. A '401 Unauthorized' points to an invalid or missing routing key. A '400 Bad Request' suggests malformed data in the `EventV2_create` call.","error":"pagerduty.EventV2_create() failed: 401 Unauthorized / 400 Bad Request"},{"fix":"Ensure you are using `PagerDutyService` (a class-based resource) and correctly instantiating it, e.g., `resources={'pagerduty': PagerDutyService(routing_key='your_key')}`. Avoid using `@resource` decorated functions if you are on a modern Dagster version.","cause":"This error occurs when an incorrect type or old-style definition is used for the PagerDuty resource, particularly with newer Dagster versions expecting Pythonic resources.","error":"dagster._core.errors.DagsterInvalidConfigError: Received an invalid value for config 'resources': Expected 'pagerduty' to be a 'ResourceDefinition'."}]}