|
| 1 | +--- |
| 2 | +subcategory: "Kibana" |
| 3 | +layout: "" |
| 4 | +page_title: "Elasticstack: elasticstack_kibana_alerting_rule Resource" |
| 5 | +description: |- |
| 6 | + Creates or updates a Kibana alerting rule. |
| 7 | +--- |
| 8 | + |
| 9 | +# Resource: elasticstack_kibana_alerting_rule |
| 10 | + |
| 11 | +Creates or updates a Kibana alerting rule. See https://www.elastic.co/guide/en/kibana/8.6/create-and-manage-rules.html |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +provider "elasticstack" { |
| 17 | + elasticsearch {} |
| 18 | +} |
| 19 | +
|
| 20 | +resource "elasticstack_kibana_alerting_rule" "example" { |
| 21 | + name = "%s" |
| 22 | + consumer = "alerts" |
| 23 | + notify_when = "onActiveAlert" |
| 24 | + params = jsonencode({ |
| 25 | + aggType = "avg" |
| 26 | + groupBy = "top" |
| 27 | + termSize = 10 |
| 28 | + timeWindowSize = 10 |
| 29 | + timeWindowUnit = "s" |
| 30 | + threshold = [10] |
| 31 | + thresholdComparator = ">" |
| 32 | + index = ["test-index"] |
| 33 | + timeField = "@timestamp" |
| 34 | + aggField = "version" |
| 35 | + termField = "name" |
| 36 | + }) |
| 37 | + rule_type_id = ".index-threshold" |
| 38 | + interval = "1m" |
| 39 | + enabled = true |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +<!-- schema generated by tfplugindocs --> |
| 44 | +## Schema |
| 45 | + |
| 46 | +### Required |
| 47 | + |
| 48 | +- `consumer` (String) The name of the application or feature that owns the rule. |
| 49 | +- `interval` (String) The check interval, which specifies how frequently the rule conditions are checked. The interval must be specified in seconds, minutes, hours or days. |
| 50 | +- `name` (String) The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule. |
| 51 | +- `notify_when` (String) Defines how often alerts generate actions. One of `onActionGroupChange`, `onActiveAlert`, or `onThrottleInterval` |
| 52 | +- `params` (String) The parameters to pass to the rule type executor params value. This will also validate against the rule type params validator, if defined. |
| 53 | +- `rule_type_id` (String) The ID of the rule type that you want to call when the rule is scheduled to run. For more information, refer to Rule types documentation (https://www.elastic.co/guide/en/kibana/master/rule-types.html). |
| 54 | + |
| 55 | +### Optional |
| 56 | + |
| 57 | +- `actions` (Block List) An array of action objects (see [below for nested schema](#nestedblock--actions)) |
| 58 | +- `enabled` (Boolean) Indicates if you want to run the rule on an interval basis |
| 59 | +- `rule_id` (String) A UUID v1 or v4 to use instead of a randomly generated ID. |
| 60 | +- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used. |
| 61 | +- `tags` (List of String) A list of tag names that are applied to the rule |
| 62 | +- `throttle` (String) Defines how often an alert generates repeated actions. This custom action interval must be specified in seconds, minutes, hours, or days. For example, 10m or 1h. This property is used only if notify_when is onThrottleInterval. |
| 63 | + |
| 64 | +### Read-Only |
| 65 | + |
| 66 | +- `id` (String) The ID of this resource. |
| 67 | +- `last_execution_date` (String) Date of the last execution of this rule. |
| 68 | +- `last_execution_status` (String) Status of the last execution of this rule. |
| 69 | +- `scheduled_task_id` (String) ID of the scheduled task that will execute the alert. |
| 70 | + |
| 71 | +<a id="nestedblock--actions"></a> |
| 72 | +### Nested Schema for `actions` |
| 73 | + |
| 74 | +Required: |
| 75 | + |
| 76 | +- `id` (String) The ID of the connector saved object. |
| 77 | +- `params` (String) The map to the `params` that the connector type will receive. |
| 78 | + |
| 79 | +Optional: |
| 80 | + |
| 81 | +- `group` (String) Grouping actions is recommended for escalations for different types of alerts. |
| 82 | + |
| 83 | +## Import |
| 84 | + |
| 85 | +Import is supported using the following syntax: |
| 86 | + |
| 87 | +```shell |
| 88 | +terraform import elasticstack_kibana_alerting_rule.my_rule <space id>/<rule id> |
| 89 | +``` |
0 commit comments