rules
Creates, updates, deletes, gets or lists a rules resource.
Overview
| Name | rules |
| Type | Resource |
| Id | pagerduty.rulesets.rules |
Fields
The following fields are returned by SELECT queries:
- get
- list
The Event Rule object.
| Name | Datatype | Description |
|---|---|---|
id | string | ID of the Event Rule. |
actions | object | When an event matches this rule, the actions that will be taken to change the resulting alert and incident. |
catch_all | boolean | Indicates whether the Event Rule is the last Event Rule of the Ruleset that serves as a catch-all. It has limited functionality compared to other rules and always matches. |
conditions | object | Conditions evaluated to check if an event matches this Event Rule. Is always empty for the catch_all rule, though. |
disabled | boolean | Indicates whether the Event Rule is disabled and would therefore not be evaluated. |
position | integer | Position/index of the Event Rule in the Ruleset. Starting from position 0 (the first rule), rules are evaluated one-by-one until a matching rule is found. |
self | string (url) | the API show URL at which the object is accessible. |
time_frame | object | Time-based conditions for limiting when the rule is active. |
variables | array | [Early Access] Populate variables from event payloads and use those variables in other event actions. |
A paginated array of Event Rule objects.
| Name | Datatype | Description |
|---|---|---|
id | string | ID of the Event Rule. |
actions | object | When an event matches this rule, the actions that will be taken to change the resulting alert and incident. |
catch_all | boolean | Indicates whether the Event Rule is the last Event Rule of the Ruleset that serves as a catch-all. It has limited functionality compared to other rules and always matches. |
conditions | object | Conditions evaluated to check if an event matches this Event Rule. Is always empty for the catch_all rule, though. |
disabled | boolean | Indicates whether the Event Rule is disabled and would therefore not be evaluated. |
position | integer | Position/index of the Event Rule in the Ruleset. Starting from position 0 (the first rule), rules are evaluated one-by-one until a matching rule is found. |
self | string (url) | the API show URL at which the object is accessible. |
time_frame | object | Time-based conditions for limiting when the rule is active. |
variables | array | [Early Access] Populate variables from event payloads and use those variables in other event actions. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | id, rule_id | Get an Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.read<br /> | |
list | select | id | limit, offset, total | List all Event Rules on a Ruleset.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.read<br /> |
create | insert | id, rule | Create a new Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.write<br /> | |
update | update | id, rule_id, rule_id | Update an Event Rule. Note that the endpoint supports partial updates, so any number of the writable fields can be provided.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.write<br /> | |
delete | delete | id, rule_id | Delete an Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Scoped OAuth requires: event_rules.write<br /> |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
id | string | The ID of the resource. |
rule_id | string | The id of the Event Rule to retrieve. |
limit | integer | The number of results per page. |
offset | integer | Offset to start pagination search results. |
total | boolean | By default the total field in pagination responses is set to null to provide the fastest possible response times. Set total to true for this field to be populated. See our [Pagination Docs](https://developer.pagerduty.com/docs/rest-api-v2/pagination/) for more information. |
SELECT examples
- get
- list
Get an Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.read<br />
SELECT
id,
actions,
catch_all,
conditions,
disabled,
position,
self,
time_frame,
variables
FROM pagerduty.rulesets.rules
WHERE id = '{{ id }}' -- required
AND rule_id = '{{ rule_id }}' -- required
;
List all Event Rules on a Ruleset.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.read<br />
SELECT
id,
actions,
catch_all,
conditions,
disabled,
position,
self,
time_frame,
variables
FROM pagerduty.rulesets.rules
WHERE id = '{{ id }}' -- required
AND limit = '{{ limit }}'
AND offset = '{{ offset }}'
AND total = '{{ total }}'
;
INSERT examples
- create
- Manifest
Create a new Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.write<br />
INSERT INTO pagerduty.rulesets.rules (
rule,
id
)
SELECT
'{{ rule }}' /* required */,
'{{ id }}'
RETURNING
rule
;
# Description fields are for documentation purposes
- name: rules
props:
- name: id
value: "{{ id }}"
description: Required parameter for the rules resource.
- name: rule
value:
id: "{{ id }}"
self: "{{ self }}"
disabled: {{ disabled }}
conditions:
operator: "{{ operator }}"
subconditions:
- operator: "{{ operator }}"
parameters:
path: "{{ path }}"
value: "{{ value }}"
options: "{{ options }}"
time_frame:
active_between:
start_time: {{ start_time }}
end_time: {{ end_time }}
scheduled_weekly:
start_time: {{ start_time }}
duration: {{ duration }}
timezone: "{{ timezone }}"
weekdays:
- {{ weekdays }}
variables:
- type: "{{ type }}"
name: "{{ name }}"
parameters:
value: "{{ value }}"
path: "{{ path }}"
position: {{ position }}
catch_all: {{ catch_all }}
actions:
annotate:
value: "{{ value }}"
event_action:
value: "{{ value }}"
extractions: "{{ extractions }}"
priority:
value: "{{ value }}"
severity:
value: "{{ value }}"
suppress:
value: {{ value }}
threshold_value: {{ threshold_value }}
threshold_time_unit: "{{ threshold_time_unit }}"
threshold_time_amount: {{ threshold_time_amount }}
suspend:
value: {{ value }}
route:
value: "{{ value }}"
UPDATE examples
- update
Update an Event Rule. Note that the endpoint supports partial updates, so any number of the writable fields can be provided.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Note: Create and Update on rules will accept 'description' or 'summary' interchangeably as an extraction action target. Get and List on rules will always return 'summary' as the target. If you are expecting 'description' please change your automation code to expect 'summary' instead.<br /><br />Scoped OAuth requires: event_rules.write<br />
UPDATE pagerduty.rulesets.rules
SET
rule = '{{ rule }}',
rule_id = '{{ rule_id }}'
WHERE
id = '{{ id }}' --required
AND rule_id = '{{ rule_id }}' --required
AND rule_id = '{{ rule_id }}' --required
RETURNING
rule;
DELETE examples
- delete
Delete an Event Rule.<br /><!-- theme: warning --><br />> ### End-of-life<br />> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.<br /><br />Rulesets allow you to route events to an endpoint and create collections of Event Rules, which define sets of actions to take based on event content.<br /><br />For more information see the [API Concepts Document](https://developer.pagerduty.com/api-reference/a47605517c19a-api-concepts#rulesets)<br /><br />Scoped OAuth requires: event_rules.write<br />
DELETE FROM pagerduty.rulesets.rules
WHERE id = '{{ id }}' --required
AND rule_id = '{{ rule_id }}' --required
;