Skip to content

Commit e5e9294

Browse files
authored
Merge pull request #57 from netdata/feat/add-notification-repeat
feat: add notification repeat option
2 parents 1987cd7 + 7f7c219 commit e5e9294

19 files changed

+314
-164
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.2.2
2+
3+
FEATURES:
4+
5+
- option to specify notification repeat interval `repeat_notification_min` for the paid notification channels
6+
17
## 0.2.1
28

39
BUGFIXES:

docs/resources/notification_discord_channel.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ Resource for managing centralized notifications for Discord. Available only in p
1616
resource "netdata_notification_discord_channel" "test" {
1717
name = "discord notifications"
1818
19-
enabled = true
20-
space_id = "<space_id>"
21-
rooms_id = ["<room_id>"]
22-
webhook_url = "https://discord.com/api/webhooks/0000000000000/XXXXXXXXXXXXXXXXXXXXXXXX"
23-
alarms = "ALARMS_SETTING_ALL"
24-
channel_type = "text"
19+
enabled = true
20+
space_id = "<space_id>"
21+
rooms_id = ["<room_id>"]
22+
repeat_notification_min = 30
23+
webhook_url = "https://discord.com/api/webhooks/0000000000000/XXXXXXXXXXXXXXXXXXXXXXXX"
24+
alarms = "ALARMS_SETTING_ALL"
25+
channel_type = "text"
2526
}
2627
```
2728

@@ -40,6 +41,7 @@ resource "netdata_notification_discord_channel" "test" {
4041
### Optional
4142

4243
- `channel_thread` (String) Discord channel thread name required if channel type is `forum`
44+
- `repeat_notification_min` (Number) The time interval for the Discord notification to be repeated. The interval is presented in minutes and should be between 30 and 1440, or 0 to avoid repetition, which is the default.
4345
- `rooms_id` (List of String) The list of room IDs to set the Discord notification. If the rooms list is null, the Discord notification will be applied to `All rooms`
4446

4547
### Read-Only

docs/resources/notification_pagerduty_channel.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ Resource for managing centralized notifications for Pagerduty. Available only in
1616
resource "netdata_notification_pagerduty_channel" "test" {
1717
name = "pagerduty notifications"
1818
19-
enabled = true
20-
space_id = netdata_space.test.id
21-
rooms_id = ["<room_id>"]
22-
alarms = "ALARMS_SETTING_ALL"
23-
alert_events_url = "https://events.pagerduty.com/v2/enqueue"
24-
integration_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
19+
enabled = true
20+
space_id = netdata_space.test.id
21+
rooms_id = ["<room_id>"]
22+
alarms = "ALARMS_SETTING_ALL"
23+
repeat_notification_min = 30
24+
alert_events_url = "https://events.pagerduty.com/v2/enqueue"
25+
integration_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2526
}
2627
```
2728

@@ -39,6 +40,7 @@ resource "netdata_notification_pagerduty_channel" "test" {
3940

4041
### Optional
4142

43+
- `repeat_notification_min` (Number) The time interval for the Pagerduty notification to be repeated. The interval is presented in minutes and should be between 30 and 1440, or 0 to avoid repetition, which is the default.
4244
- `rooms_id` (List of String) The list of room IDs to set the Pagerduty notification. If the rooms list is null, the Pagerduty notification will be applied to `All rooms`
4345

4446
### Read-Only

docs/resources/notification_slack_channel.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ Resource for managing centralized notifications for Slack. Available only in pai
1616
resource "netdata_notification_slack_channel" "test" {
1717
name = "slack notifications"
1818
19-
enabled = true
20-
space_id = "<space_id>"
21-
rooms_id = ["<room_id>"]
22-
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
23-
alarms = "ALARMS_SETTING_ALL"
19+
enabled = true
20+
space_id = "<space_id>"
21+
rooms_id = ["<room_id>"]
22+
repeat_notification_min = 30
23+
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
24+
alarms = "ALARMS_SETTING_ALL"
2425
}
2526
```
2627

@@ -37,6 +38,7 @@ resource "netdata_notification_slack_channel" "test" {
3738

3839
### Optional
3940

41+
- `repeat_notification_min` (Number) The time interval for the Slack notification to be repeated. The interval is presented in minutes and should be between 30 and 1440, or 0 to avoid repetition, which is the default.
4042
- `rooms_id` (List of String) The list of room IDs to set the Slack notification. If the rooms list is null, the Slack notification will be applied to `All rooms`
4143

4244
### Read-Only

examples/complete/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ resource "netdata_node_room_member" "test" {
4444
resource "netdata_notification_slack_channel" "test" {
4545
name = "slack"
4646

47-
enabled = true
48-
space_id = netdata_space.test.id
49-
rooms_id = [netdata_room.test.id]
50-
alarms = "ALARMS_SETTING_ALL"
51-
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
47+
enabled = true
48+
space_id = netdata_space.test.id
49+
rooms_id = [netdata_room.test.id]
50+
alarms = "ALARMS_SETTING_ALL"
51+
repeat_notification_min = 60
52+
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
5253
}
5354

5455
resource "netdata_notification_discord_channel" "test" {
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
resource "netdata_notification_discord_channel" "test" {
22
name = "discord notifications"
33

4-
enabled = true
5-
space_id = "<space_id>"
6-
rooms_id = ["<room_id>"]
7-
webhook_url = "https://discord.com/api/webhooks/0000000000000/XXXXXXXXXXXXXXXXXXXXXXXX"
8-
alarms = "ALARMS_SETTING_ALL"
9-
channel_type = "text"
4+
enabled = true
5+
space_id = "<space_id>"
6+
rooms_id = ["<room_id>"]
7+
repeat_notification_min = 30
8+
webhook_url = "https://discord.com/api/webhooks/0000000000000/XXXXXXXXXXXXXXXXXXXXXXXX"
9+
alarms = "ALARMS_SETTING_ALL"
10+
channel_type = "text"
1011
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
resource "netdata_notification_pagerduty_channel" "test" {
22
name = "pagerduty notifications"
33

4-
enabled = true
5-
space_id = netdata_space.test.id
6-
rooms_id = ["<room_id>"]
7-
alarms = "ALARMS_SETTING_ALL"
8-
alert_events_url = "https://events.pagerduty.com/v2/enqueue"
9-
integration_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
4+
enabled = true
5+
space_id = netdata_space.test.id
6+
rooms_id = ["<room_id>"]
7+
alarms = "ALARMS_SETTING_ALL"
8+
repeat_notification_min = 30
9+
alert_events_url = "https://events.pagerduty.com/v2/enqueue"
10+
integration_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
1011
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
resource "netdata_notification_slack_channel" "test" {
22
name = "slack notifications"
33

4-
enabled = true
5-
space_id = "<space_id>"
6-
rooms_id = ["<room_id>"]
7-
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
8-
alarms = "ALARMS_SETTING_ALL"
4+
enabled = true
5+
space_id = "<space_id>"
6+
rooms_id = ["<room_id>"]
7+
repeat_notification_min = 30
8+
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
9+
alarms = "ALARMS_SETTING_ALL"
910
}

internal/client/models.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ type NotificationIntegrations struct {
2929
}
3030

3131
type NotificationChannel struct {
32-
ID string `json:"id"`
33-
Enabled bool `json:"enabled"`
34-
Name string `json:"name"`
35-
Integration NotificationIntegration `json:"integration"`
36-
Alarms string `json:"alarms"`
37-
Rooms []string `json:"rooms"`
38-
Secrets json.RawMessage `json:"secrets"`
32+
ID string `json:"id"`
33+
Enabled bool `json:"enabled"`
34+
Name string `json:"name"`
35+
Integration NotificationIntegration `json:"integration"`
36+
Alarms string `json:"alarms"`
37+
Rooms []string `json:"rooms"`
38+
Secrets json.RawMessage `json:"secrets"`
39+
RepeatNotificationMinute int64 `json:"repeat_notification_min,omitempty"`
3940
}
4041

4142
type NotificationIntegration struct {
@@ -61,11 +62,12 @@ type NotificationPagerdutyChannel struct {
6162
}
6263

6364
type notificationRequestPayload struct {
64-
Name string `json:"name"`
65-
IntegrationID string `json:"integrationID"`
66-
Alarms string `json:"alarms"`
67-
Rooms []string `json:"rooms"`
68-
Secrets json.RawMessage `json:"secrets"`
65+
Name string `json:"name"`
66+
IntegrationID string `json:"integrationID"`
67+
Alarms string `json:"alarms"`
68+
Rooms []string `json:"rooms"`
69+
Secrets json.RawMessage `json:"secrets"`
70+
RepeatNotificationMinute int64 `json:"repeat_notification_min,omitempty"`
6971
}
7072

7173
type Invitation struct {

internal/client/notification_discord.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ func (c *Client) CreateDiscordChannel(spaceID string, commonParams NotificationC
1414
}
1515

1616
reqBody := notificationRequestPayload{
17-
Name: commonParams.Name,
18-
IntegrationID: commonParams.Integration.ID,
19-
Rooms: commonParams.Rooms,
20-
Alarms: commonParams.Alarms,
17+
Name: commonParams.Name,
18+
IntegrationID: commonParams.Integration.ID,
19+
Rooms: commonParams.Rooms,
20+
Alarms: commonParams.Alarms,
21+
RepeatNotificationMinute: commonParams.RepeatNotificationMinute,
2122
}
2223

2324
secretsJson, err := json.Marshal(discordParams)
@@ -70,9 +71,10 @@ func (c *Client) UpdateDiscordChannelByID(spaceID string, commonParams Notificat
7071
}
7172

7273
reqBody := notificationRequestPayload{
73-
Name: commonParams.Name,
74-
Rooms: commonParams.Rooms,
75-
Alarms: commonParams.Alarms,
74+
Name: commonParams.Name,
75+
Rooms: commonParams.Rooms,
76+
Alarms: commonParams.Alarms,
77+
RepeatNotificationMinute: commonParams.RepeatNotificationMinute,
7678
}
7779

7880
secretsJson, err := json.Marshal(discordParams)

0 commit comments

Comments
 (0)