Skip to content

Commit c053f4b

Browse files
authored
1.14 (#175)
* 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
1 parent 3d80d6b commit c053f4b

40 files changed

+4514
-170
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
AWS_ARN: ${{ secrets.AWS_ARN }}
1919
AWS_ACCESS_KEY_UPDATE: ${{ secrets.AWS_ACCESS_KEY_UPDATE }}
2020
AWS_SECRET_KEY_UPDATE: ${{ secrets.AWS_SECRET_KEY_UPDATE }}
21+
GRAFANA_FOLDER_UID: ${{ secrets.GRAFANA_FOLDER_UID }}
2122

2223
jobs:
2324
test:

docs/data-sources/grafana_folder.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Grafana Folder Datasource
2+
3+
Use this data source to access information about existing Logz.io Grafana folder.
4+
5+
## Argument Reference
6+
7+
- `title` - (String) The title of the folder.
8+
9+
## Attribute Reference
10+
11+
- `uid` - (String) Unique identifier for the folder.
12+
- `folder_id` - (Integer) Auto-incrementing numeric value.
13+
- `url` - (String) Url for the folder.
14+
- `version` - (Integer) Version number of the folder.
15+
16+

docs/resources/grafana_alert_rule.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Grafana Alert Rule Resource
2+
3+
Provides a Logz.io Grafana alert rule resource. This can be used to create and manage Grafana alert rules in Logz.io.
4+
5+
* Learn more about Logz.io's Grafana alert rule API in [Logz.io Docs](https://docs.logz.io/api/#tag/Grafana-alerting-provisioning).
6+
7+
## Example Usage
8+
9+
```hcl
10+
resource "logzio_grafana_alert_rule" "test_grafana_alert" {
11+
annotations = {
12+
"foo" = "bar"
13+
"hello" = "world"
14+
}
15+
condition = "A"
16+
data {
17+
ref_id = "B"
18+
datasource_uid = "AB1C234567D89012E"
19+
query_type = ""
20+
model = jsonencode({
21+
hide = false
22+
refId = "B"
23+
})
24+
relative_time_range {
25+
from = 700
26+
to = 0
27+
}
28+
}
29+
labels = {
30+
"hey" = "oh"
31+
"lets" = "go"
32+
}
33+
is_paused = false
34+
exec_err_state = "Alerting"
35+
folder_uid = "my-folder-uid"
36+
for = "3m"
37+
no_data_state = "OK"
38+
rule_group = "rule_group_1"
39+
title = "my_grafana_alert"
40+
}
41+
```
42+
43+
## Argument Reference
44+
45+
### Required:
46+
47+
* `condition` - (String) The `ref_id` of the query node in the `data` field to use as the alert condition.
48+
* `data` - (Block List) A sequence of stages that describe the contents of the rule. See below for **nested schema**.
49+
* `folder_uid` - (String) The UID of the folder that the alert rule belongs to.
50+
* `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".
51+
* `rule_group` - (String) The rule group this rule is associated with.
52+
* `title` - (String) The title of this rule.
53+
54+
### Optional:
55+
56+
* `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.
57+
* `labels` - (Map of String) Key-value pairs to attach to the alert rule that can be used in matching, grouping, and routing.
58+
* `is_paused` - (Boolean) Sets whether the alert should be paused or not. Defaults to `false`.
59+
* `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`.
60+
* `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`.
61+
62+
#### Nested schema for `data`:
63+
64+
##### Required:
65+
66+
* `ref_id` - (String) A unique string to identify this query stage within a rule.
67+
* `datasource_uid` - (String) The UID of the datasource being queried, or "-100" if this stage is an expression stage.
68+
* `model` - (String) Custom JSON data to send to the specified datasource when querying.
69+
* `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**.
70+
71+
##### Optional:
72+
73+
* `query_type` - (String) An optional identifier for the type of query being executed.
74+
75+
#### Nested schema for `data.relative_time_range`:
76+
77+
##### Required:
78+
79+
* `from` - (Integer) The number of seconds in the past, relative to when the rule is evaluated, at which the time range begins.
80+
* `to` - (Integer) The number of seconds in the past, relative to when the rule is evaluated, at which the time range ends.
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
# Grafana Contact Point
2+
3+
Provides a Logz.io Grafana Contact Point resource. This can be used to create and manage Logz.io Grafana Contact Points.
4+
5+
* Learn more about grafana contact points in the [Logz.io Docs](https://docs.logz.io/api/#tag/Grafana-contact-points).
6+
7+
## Example Usage
8+
9+
```hcl
10+
variable "api_token" {
11+
type = string
12+
description = "your logzio API token"
13+
}
14+
15+
provider "logzio" {
16+
api_token = var.api_token
17+
}
18+
19+
resource "logzio_grafana_contact_point" "test_cp_email" {
20+
name = "my-email-cp"
21+
email {
22+
addresses = ["example@example.com", "example2@example.com"]
23+
disable_resolve_message = false
24+
single_email = true
25+
message = "{{ len .Alerts.Firing }} firing."
26+
}
27+
}
28+
29+
resource "logzio_grafana_contact_point" "test_cp_googlechat" {
30+
name = "my-googlechat-cp"
31+
googlechat {
32+
url = "some.url"
33+
disable_resolve_message = false
34+
message = "{{ len .Alerts.Firing }} firing."
35+
}
36+
}
37+
38+
resource "logzio_grafana_contact_point" "test_cp_opsgenie" {
39+
name = "my-opsgenie-cp"
40+
opsgenie {
41+
disable_resolve_message = false
42+
api_url = "some.url"
43+
api_key = "some_api_key"
44+
auto_close = false
45+
override_priority = true
46+
send_tags_as = "both"
47+
}
48+
}
49+
50+
resource "logzio_grafana_contact_point" "test_cp_pagerduty" {
51+
name = "my-pagerduty-cp"
52+
pagerduty {
53+
integration_key = "some-key"
54+
class = "some-class"
55+
component = "some-component"
56+
group = "some-group"
57+
severity = "info"
58+
disable_resolve_message = false
59+
}
60+
}
61+
62+
resource "logzio_grafana_contact_point" "test_cp_slack" {
63+
name = "my-slack-cp"
64+
slack {
65+
token = "some-token"
66+
title = "some-title"
67+
text = "{{ len .Alerts.Firing }} firing."
68+
mention_channel = "here"
69+
recipient = "me"
70+
disable_resolve_message = false
71+
}
72+
}
73+
74+
resource "logzio_grafana_contact_point" "test_cp_teams" {
75+
name = "my-teams-cp"
76+
teams {
77+
url = "url"
78+
message = "message"
79+
disable_resolve_message = false
80+
}
81+
}
82+
83+
resource "logzio_grafana_contact_point" "test_cp_victorops" {
84+
name = "my-victorops-cp"
85+
victorops {
86+
url = "url"
87+
message_type = "CRITICAL"
88+
disable_resolve_message = false
89+
}
90+
}
91+
92+
resource "logzio_grafana_contact_point" "test_cp_webhook" {
93+
name = "my-webhook-cp"
94+
webhook {
95+
url = "url"
96+
disable_resolve_message = false
97+
}
98+
opsgenie {
99+
disable_resolve_message = false
100+
api_url = "some.url"
101+
api_key = "some_api_key"
102+
auto_close = false
103+
override_priority = true
104+
send_tags_as = "both"
105+
}
106+
}
107+
108+
```
109+
110+
## Argument Reference
111+
112+
### Required:
113+
114+
* `name` - (String) The name of your contact point.
115+
116+
### Optional:
117+
118+
* `email` - (Block List) A contact point that sends notifications to an email address. See below for **nested schema**.
119+
* `googlechat` - (Block List) A contact point that sends notifications to Google Chat. See below for **nested schema**.
120+
* `opsgenie` - (Block List) A contact point that sends notifications to OpsGenie. See below for **nested schema**.
121+
* `pagerduty` - (Block List) A contact point that sends notifications to PagerDuty. See below for **nested schema**.
122+
* `slack` - (Block List) A contact point that sends notifications to Slack. See below for **nested schema**.
123+
* `teams` - (Block List) A contact point that sends notifications to Microsoft Teams. See below for **nested schema**.
124+
* `victorops` - (Block List) A contact point that sends notifications to VictorOps. See below for **nested schema**.
125+
* `webhook` - (Block List) A contact point that sends notifications to an arbitrary webhook. See below for **nested schema**.
126+
127+
## Attribute Reference
128+
129+
* `id` - (String) The ID of this resource.
130+
131+
## Nested schema for `email`:
132+
133+
### Argument Reference
134+
135+
#### Required:
136+
137+
* `addresses` - (List of String) The addresses to send emails to.
138+
139+
#### Optional:
140+
141+
* `single_email` - (Boolean) Whether to send a single email CC'ing all addresses, rather than a separate email to each address. Defaults to `false`.
142+
* `message` - (String) The templated content of the email. Defaults to ``.
143+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
144+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
145+
146+
### Attribute Reference
147+
148+
* `uid` - (String) The UID of the contact point.
149+
150+
## Nested schema for `googlechat`:
151+
152+
#### Required:
153+
154+
* `url` - (String, Sensitive) The Google Chat webhook URL.
155+
156+
#### Optional:
157+
158+
* `message` - (String) The templated content of the message.
159+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
160+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
161+
162+
### Attribute Reference
163+
164+
* `uid` - (String) The UID of the contact point.
165+
166+
## Nested schema for `opsgenie`:
167+
168+
#### Required:
169+
170+
* `api_key` - (String, Sensitive) The OpsGenie API key to use.
171+
172+
#### Optional:
173+
174+
* `api_url` - (String) Allows customization of the OpsGenie API URL.
175+
* `auto_close` - (Boolean) Whether to auto-close alerts in OpsGenie when they resolve in the Alertmanager.
176+
* `override_priority` - (Boolean) Whether to allow the alert priority to be configured via the value of the og_priority annotation on the alert.
177+
* `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.
178+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
179+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
180+
181+
### Attribute Reference
182+
183+
* `uid` - (String) The UID of the contact point.
184+
185+
## Nested schema for `pagerduty`:
186+
187+
#### Required:
188+
189+
* `integration_key` - (String, Sensitive) The PagerDuty API key.
190+
191+
#### Optional:
192+
193+
* `class` - (String) The class or type of event.
194+
* `component` - (String) The component being affected by the event.
195+
* `group` - (String) The group to which the provided component belongs to.
196+
* `summary` - (String) The templated summary message of the event.
197+
* `severity` - (String) The PagerDuty event severity level. Can be one of `info`, `warning`, `error`, `critical`.
198+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
199+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
200+
201+
### Attribute Reference
202+
203+
* `uid` - (String) The UID of the contact point.
204+
205+
## Nested schema for `slack`:
206+
207+
#### Required:
208+
209+
* `recipient` - (String) Channel, private group, or IM channel (can be an encoded ID or a name) to send messages to.
210+
211+
#### Optional:
212+
213+
* `endpoint_url` - (String) Use this to override the Slack API endpoint URL to send requests to.
214+
* `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.
215+
* `mention_groups` - (String) Comma-separated list of groups to mention in the message.
216+
* `mention_users` - (String) Comma-separated list of users to mention in the message.
217+
* `text` - (String) Templated content of the message.
218+
* `title` - (String) Templated title of the message.
219+
* `token` - (String, Sensitive) A Slack API token,for sending messages directly without the webhook method.
220+
* `url` - (String, Sensitive) A Slack webhook URL,for sending messages via the webhook method.
221+
* `username` - (String) Username for the bot to use.
222+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
223+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
224+
225+
### Attribute Reference
226+
227+
* `uid` - (String) The UID of the contact point.
228+
229+
## Nested schema for `teams`:
230+
231+
#### Required:
232+
233+
* `url` - (String, Sensitive) A Teams webhook URL.
234+
235+
#### Optional:
236+
237+
* `message` - (String) The templated message content to send.
238+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
239+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
240+
241+
### Attribute Reference
242+
243+
* `uid` - (String) The UID of the contact point.
244+
245+
## Nested schema for `victorops`:
246+
247+
#### Required:
248+
249+
* `url` - (String) The VictorOps webhook URL.
250+
251+
#### Optional:
252+
253+
* `message_type` - (String) The VictorOps alert state - typically either `CRITICAL` or `WARNING`.
254+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
255+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
256+
257+
### Attribute Reference
258+
259+
* `uid` - (String) The UID of the contact point.
260+
261+
## Nested schema for `webhook`:
262+
263+
#### Required:
264+
265+
* `url` - (String) The URL to send webhook requests to.
266+
267+
#### Optional:
268+
269+
* `http_method` - (String) The HTTP method to use in the request. Can be either `PUT` or `POST`.
270+
* `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.
271+
* `password` - (String, Sensitive) The username to use in basic auth headers attached to the request. If omitted, basic auth will not be used.
272+
* `username` - (String) The username to use in basic auth headers attached to the request. If omitted, basic auth will not be used.
273+
* `disable_resolve_message` - (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
274+
* `settings` - (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.
275+
276+
### Attribute Reference
277+
278+
* `uid` - (String) The UID of the contact point.
279+
280+
## Import contact point as resource
281+
282+
You can import contact point as follows:
283+
284+
```
285+
terraform import logzio_grafana_contact_point.my_cp <CONTACT-POINT-NAME>
286+
```

0 commit comments

Comments
 (0)