-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Grafana notification policy (#173) * add validator and parser * save progress - create obj from schema * finish create * read * update * delete * add to provider * remove alert v1 test * fix missing assigns * tests * examples * docs, example * Grafana alerts (#171) * save progress * grafana alert, validators update * save progress * remove redundent condition * read * update * update, add resource to provider * rename file * start test, fix types * save progress * save progress - no runtime errors * fix org id issue * save progress - tests, import issue * fix org id issue * finish resource test * add example * fix example folder uid * save progress - change required, readme, docs * fix for field * docs, fix optional * add note * add test * tests * go mod * readme * Grafana contact point (#174) * save progress - start of resource * add fields to schema * validation * export function, contact point create * save progress - read * read * update, delete * update provider * fix email address * fix contact point * email * googlechat * opsgenie * pagerduty * slack * teams * webhook * webhook * refactor email * refactor googlechat * refactor opsgenie * refactor pagerduty * refactor slack * refactor teams * refactor victorops * refactor webhook * fix update * import * examples * docs * Grafana folders (#158) * resource, precommit hook * rm git secrets workflow * uid computed, test, upgrade module tf plugin sdk * add resource to provider * add datasource * main readme * example * docs resource * doc datasource * upgrade logzio client in go mod, remove alert v1 utils functions and tests * upgrade modules * readme * fix validator * changelog * add warning on mute timings * fix changelog
- Loading branch information
Showing
40 changed files
with
4,514 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Grafana Folder Datasource | ||
|
||
Use this data source to access information about existing Logz.io Grafana folder. | ||
|
||
## Argument Reference | ||
|
||
- `title` - (String) The title of the folder. | ||
|
||
## Attribute Reference | ||
|
||
- `uid` - (String) Unique identifier for the folder. | ||
- `folder_id` - (Integer) Auto-incrementing numeric value. | ||
- `url` - (String) Url for the folder. | ||
- `version` - (Integer) Version number of the folder. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Grafana Alert Rule Resource | ||
|
||
Provides a Logz.io Grafana alert rule resource. This can be used to create and manage Grafana alert rules in Logz.io. | ||
|
||
* Learn more about Logz.io's Grafana alert rule API in [Logz.io Docs](https://docs.logz.io/api/#tag/Grafana-alerting-provisioning). | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
resource "logzio_grafana_alert_rule" "test_grafana_alert" { | ||
annotations = { | ||
"foo" = "bar" | ||
"hello" = "world" | ||
} | ||
condition = "A" | ||
data { | ||
ref_id = "B" | ||
datasource_uid = "AB1C234567D89012E" | ||
query_type = "" | ||
model = jsonencode({ | ||
hide = false | ||
refId = "B" | ||
}) | ||
relative_time_range { | ||
from = 700 | ||
to = 0 | ||
} | ||
} | ||
labels = { | ||
"hey" = "oh" | ||
"lets" = "go" | ||
} | ||
is_paused = false | ||
exec_err_state = "Alerting" | ||
folder_uid = "my-folder-uid" | ||
for = "3m" | ||
no_data_state = "OK" | ||
rule_group = "rule_group_1" | ||
title = "my_grafana_alert" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
### Required: | ||
|
||
* `condition` - (String) The `ref_id` of the query node in the `data` field to use as the alert condition. | ||
* `data` - (Block List) A sequence of stages that describe the contents of the rule. See below for **nested schema**. | ||
* `folder_uid` - (String) The UID of the folder that the alert rule belongs to. | ||
* `for` - (String) The amount of time for which the rule must be breached for the rule to be considered to be Firing. Before this time has elapsed, the rule is only considered to be Pending. Should be in a duration string format, for example "3m0s". | ||
* `rule_group` - (String) The rule group this rule is associated with. | ||
* `title` - (String) The title of this rule. | ||
|
||
### Optional: | ||
|
||
* `annotations` - (Map of String) Key-value pairs of metadata to attach to the alert rule that may add user-defined context, but cannot be used for matching, grouping, or routing. | ||
* `labels` - (Map of String) Key-value pairs to attach to the alert rule that can be used in matching, grouping, and routing. | ||
* `is_paused` - (Boolean) Sets whether the alert should be paused or not. Defaults to `false`. | ||
* `exec_err_state` - (String) Describes what state to enter when the rule's query is invalid and the rule cannot be executed. Options are `OK`, `Error`, and `Alerting`. Defaults to `Alerting`. | ||
* `no_data_state` - (String) Describes what state to enter when the rule's query returns No Data. Options are `OK`, `NoData`, and `Alerting`. Defaults to `NoData`. | ||
|
||
#### Nested schema for `data`: | ||
|
||
##### Required: | ||
|
||
* `ref_id` - (String) A unique string to identify this query stage within a rule. | ||
* `datasource_uid` - (String) The UID of the datasource being queried, or "-100" if this stage is an expression stage. | ||
* `model` - (String) Custom JSON data to send to the specified datasource when querying. | ||
* `relative_time_range` - (Block List, Min: 1, Max: 1) The time range, relative to when the query is executed, across which to query. See below for **nested schema**. | ||
|
||
##### Optional: | ||
|
||
* `query_type` - (String) An optional identifier for the type of query being executed. | ||
|
||
#### Nested schema for `data.relative_time_range`: | ||
|
||
##### Required: | ||
|
||
* `from` - (Integer) The number of seconds in the past, relative to when the rule is evaluated, at which the time range begins. | ||
* `to` - (Integer) The number of seconds in the past, relative to when the rule is evaluated, at which the time range ends. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,286 @@ | ||
# Grafana Contact Point | ||
|
||
Provides a Logz.io Grafana Contact Point resource. This can be used to create and manage Logz.io Grafana Contact Points. | ||
|
||
* Learn more about grafana contact points in the [Logz.io Docs](https://docs.logz.io/api/#tag/Grafana-contact-points). | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "api_token" { | ||
type = string | ||
description = "your logzio API token" | ||
} | ||
provider "logzio" { | ||
api_token = var.api_token | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_email" { | ||
name = "my-email-cp" | ||
email { | ||
addresses = ["[email protected]", "[email protected]"] | ||
disable_resolve_message = false | ||
single_email = true | ||
message = "{{ len .Alerts.Firing }} firing." | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_googlechat" { | ||
name = "my-googlechat-cp" | ||
googlechat { | ||
url = "some.url" | ||
disable_resolve_message = false | ||
message = "{{ len .Alerts.Firing }} firing." | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_opsgenie" { | ||
name = "my-opsgenie-cp" | ||
opsgenie { | ||
disable_resolve_message = false | ||
api_url = "some.url" | ||
api_key = "some_api_key" | ||
auto_close = false | ||
override_priority = true | ||
send_tags_as = "both" | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_pagerduty" { | ||
name = "my-pagerduty-cp" | ||
pagerduty { | ||
integration_key = "some-key" | ||
class = "some-class" | ||
component = "some-component" | ||
group = "some-group" | ||
severity = "info" | ||
disable_resolve_message = false | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_slack" { | ||
name = "my-slack-cp" | ||
slack { | ||
token = "some-token" | ||
title = "some-title" | ||
text = "{{ len .Alerts.Firing }} firing." | ||
mention_channel = "here" | ||
recipient = "me" | ||
disable_resolve_message = false | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_teams" { | ||
name = "my-teams-cp" | ||
teams { | ||
url = "url" | ||
message = "message" | ||
disable_resolve_message = false | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_victorops" { | ||
name = "my-victorops-cp" | ||
victorops { | ||
url = "url" | ||
message_type = "CRITICAL" | ||
disable_resolve_message = false | ||
} | ||
} | ||
resource "logzio_grafana_contact_point" "test_cp_webhook" { | ||
name = "my-webhook-cp" | ||
webhook { | ||
url = "url" | ||
disable_resolve_message = false | ||
} | ||
opsgenie { | ||
disable_resolve_message = false | ||
api_url = "some.url" | ||
api_key = "some_api_key" | ||
auto_close = false | ||
override_priority = true | ||
send_tags_as = "both" | ||
} | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
### Required: | ||
|
||
* `name` - (String) The name of your contact point. | ||
|
||
### Optional: | ||
|
||
* `email` - (Block List) A contact point that sends notifications to an email address. See below for **nested schema**. | ||
* `googlechat` - (Block List) A contact point that sends notifications to Google Chat. See below for **nested schema**. | ||
* `opsgenie` - (Block List) A contact point that sends notifications to OpsGenie. See below for **nested schema**. | ||
* `pagerduty` - (Block List) A contact point that sends notifications to PagerDuty. See below for **nested schema**. | ||
* `slack` - (Block List) A contact point that sends notifications to Slack. See below for **nested schema**. | ||
* `teams` - (Block List) A contact point that sends notifications to Microsoft Teams. See below for **nested schema**. | ||
* `victorops` - (Block List) A contact point that sends notifications to VictorOps. See below for **nested schema**. | ||
* `webhook` - (Block List) A contact point that sends notifications to an arbitrary webhook. See below for **nested schema**. | ||
|
||
## Attribute Reference | ||
|
||
* `id` - (String) The ID of this resource. | ||
|
||
## Nested schema for `email`: | ||
|
||
### Argument Reference | ||
|
||
#### Required: | ||
|
||
* `addresses` - (List of String) The addresses to send emails to. | ||
|
||
#### Optional: | ||
|
||
* `single_email` - (Boolean) Whether to send a single email CC'ing all addresses, rather than a separate email to each address. Defaults to `false`. | ||
* `message` - (String) The templated content of the email. Defaults to ``. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `googlechat`: | ||
|
||
#### Required: | ||
|
||
* `url` - (String, Sensitive) The Google Chat webhook URL. | ||
|
||
#### Optional: | ||
|
||
* `message` - (String) The templated content of the message. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `opsgenie`: | ||
|
||
#### Required: | ||
|
||
* `api_key` - (String, Sensitive) The OpsGenie API key to use. | ||
|
||
#### Optional: | ||
|
||
* `api_url` - (String) Allows customization of the OpsGenie API URL. | ||
* `auto_close` - (Boolean) Whether to auto-close alerts in OpsGenie when they resolve in the Alertmanager. | ||
* `override_priority` - (Boolean) Whether to allow the alert priority to be configured via the value of the og_priority annotation on the alert. | ||
* `send_tags_as` - (String) Whether to send annotations to OpsGenie as Tags, Details, or both. Supported values are `tags`, `details`, `both`, or empty to use the default behavior of Tags. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `pagerduty`: | ||
|
||
#### Required: | ||
|
||
* `integration_key` - (String, Sensitive) The PagerDuty API key. | ||
|
||
#### Optional: | ||
|
||
* `class` - (String) The class or type of event. | ||
* `component` - (String) The component being affected by the event. | ||
* `group` - (String) The group to which the provided component belongs to. | ||
* `summary` - (String) The templated summary message of the event. | ||
* `severity` - (String) The PagerDuty event severity level. Can be one of `info`, `warning`, `error`, `critical`. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `slack`: | ||
|
||
#### Required: | ||
|
||
* `recipient` - (String) Channel, private group, or IM channel (can be an encoded ID or a name) to send messages to. | ||
|
||
#### Optional: | ||
|
||
* `endpoint_url` - (String) Use this to override the Slack API endpoint URL to send requests to. | ||
* `mention_channel` - (String) Describes how to ping the slack channel that messages are being sent to. Options are `here` for an @here ping, `channel` for @channel, or empty for no ping. | ||
* `mention_groups` - (String) Comma-separated list of groups to mention in the message. | ||
* `mention_users` - (String) Comma-separated list of users to mention in the message. | ||
* `text` - (String) Templated content of the message. | ||
* `title` - (String) Templated title of the message. | ||
* `token` - (String, Sensitive) A Slack API token,for sending messages directly without the webhook method. | ||
* `url` - (String, Sensitive) A Slack webhook URL,for sending messages via the webhook method. | ||
* `username` - (String) Username for the bot to use. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `teams`: | ||
|
||
#### Required: | ||
|
||
* `url` - (String, Sensitive) A Teams webhook URL. | ||
|
||
#### Optional: | ||
|
||
* `message` - (String) The templated message content to send. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `victorops`: | ||
|
||
#### Required: | ||
|
||
* `url` - (String) The VictorOps webhook URL. | ||
|
||
#### Optional: | ||
|
||
* `message_type` - (String) The VictorOps alert state - typically either `CRITICAL` or `WARNING`. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Nested schema for `webhook`: | ||
|
||
#### Required: | ||
|
||
* `url` - (String) The URL to send webhook requests to. | ||
|
||
#### Optional: | ||
|
||
* `http_method` - (String) The HTTP method to use in the request. Can be either `PUT` or `POST`. | ||
* `max_alerts` - (Number) The maximum number of alerts to send in a single request. This can be helpful in limiting the size of the request body. The default is 0, which indicates no limit. | ||
* `password` - (String, Sensitive) The username to use in basic auth headers attached to the request. If omitted, basic auth will not be used. | ||
* `username` - (String) The username to use in basic auth headers attached to the request. If omitted, basic auth will not be used. | ||
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`. | ||
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`. | ||
|
||
### Attribute Reference | ||
|
||
* `uid` - (String) The UID of the contact point. | ||
|
||
## Import contact point as resource | ||
|
||
You can import contact point as follows: | ||
|
||
``` | ||
terraform import logzio_grafana_contact_point.my_cp <CONTACT-POINT-NAME> | ||
``` |
Oops, something went wrong.