File tree Expand file tree Collapse file tree 13 files changed +243
-0
lines changed Expand file tree Collapse file tree 13 files changed +243
-0
lines changed Original file line number Diff line number Diff line change
1
+ module "slack_channel" {
2
+ source = " ../../modules/channel/slack"
3
+
4
+ id = " test_slack"
5
+ name = " Test slack channel"
6
+ webhook_url = " https://hooks.slack.com/services/test"
7
+ }
8
+
9
+ module "monitor" {
10
+ source = " ../../modules/monitor"
11
+
12
+ body = {
13
+ name = " test-monitor"
14
+ type = " monitor"
15
+ enabled = true
16
+
17
+ schedule = {
18
+ period = {
19
+ interval = 1
20
+ unit = " MINUTES"
21
+ }
22
+ }
23
+
24
+ inputs = [
25
+ {
26
+ search = {
27
+ indices = [" movies" ]
28
+ query = {
29
+ size = 0
30
+ aggregations = {}
31
+ query = {
32
+ bool = {
33
+ adjust_pure_negative = true
34
+ boost = 1
35
+
36
+ filter = [
37
+ {
38
+ range = {
39
+ " @timestamp" = {
40
+ boost = 1
41
+ from = " ||-1h"
42
+ to = " "
43
+ include_lower = true
44
+ include_upper = true
45
+ format = " epoch_millis"
46
+ }
47
+ }
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ]
56
+
57
+ triggers = [
58
+ {
59
+ name = " Errors"
60
+ severity = " 1"
61
+
62
+ condition = {
63
+ script = {
64
+ source = " ctx.results[0].hits.total.value > 0"
65
+ lang = " painless"
66
+ }
67
+ }
68
+
69
+ actions = [
70
+ {
71
+ name = " Slack"
72
+ destination_id = module.slack_channel.id
73
+ throttle_enabled = false
74
+ message_template = {
75
+ source = " bogus"
76
+ lang = " mustache"
77
+ }
78
+ subject_template = {
79
+ source = " Production Errors"
80
+ lang = " mustache"
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }
87
+ }
Original file line number Diff line number Diff line change
1
+ provider "opensearch" {
2
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.4"
3
+
4
+ required_providers {
5
+ opensearch = {
6
+ source = " opensearch-project/opensearch"
7
+ version = " ~> 2.3.0"
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ ## Requirements
2
+
3
+ | Name | Version |
4
+ | ------| ---------|
5
+ | <a name =" requirement_terraform " ></a > [ terraform] ( #requirement\_ terraform ) | >= 1.4 |
6
+ | <a name =" requirement_opensearch " ></a > [ opensearch] ( #requirement\_ opensearch ) | >= 2.0 |
7
+
8
+ ## Providers
9
+
10
+ | Name | Version |
11
+ | ------| ---------|
12
+ | <a name =" provider_opensearch " ></a > [ opensearch] ( #provider\_ opensearch ) | >= 2.0 |
13
+
14
+ ## Modules
15
+
16
+ No modules.
17
+
18
+ ## Resources
19
+
20
+ | Name | Type |
21
+ | ------| ------|
22
+ | [ opensearch_channel_configuration.this] ( https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/channel_configuration ) | resource |
23
+
24
+ ## Inputs
25
+
26
+ | Name | Description | Type | Default | Required |
27
+ | ------| -------------| ------| ---------| :--------:|
28
+ | <a name =" input_description " ></a > [ description] ( #input\_ description ) | Channel config description | ` string ` | ` "" ` | no |
29
+ | <a name =" input_id " ></a > [ id] ( #input\_ id ) | Channel config ID | ` string ` | n/a | yes |
30
+ | <a name =" input_name " ></a > [ name] ( #input\_ name ) | Channel config name | ` string ` | n/a | yes |
31
+ | <a name =" input_webhook_url " ></a > [ webhook\_ url] ( #input\_ webhook\_ url ) | Slack webhook URL | ` string ` | n/a | yes |
32
+
33
+ ## Outputs
34
+
35
+ | Name | Description |
36
+ | ------| -------------|
37
+ | <a name =" output_id " ></a > [ id] ( #output\_ id ) | The ID of the channel configuration |
Original file line number Diff line number Diff line change
1
+ resource "opensearch_channel_configuration" "this" {
2
+ body = jsonencode (
3
+ {
4
+ config_id = var.id
5
+
6
+ config = {
7
+ name = var.name
8
+ description = var.description
9
+ config_type = " slack"
10
+ is_enabled = true
11
+
12
+ slack = {
13
+ url = var.webhook_url
14
+ }
15
+ }
16
+ }
17
+ )
18
+ }
Original file line number Diff line number Diff line change
1
+ output "id" {
2
+ description = " The ID of the channel configuration"
3
+ value = opensearch_channel_configuration. this . id
4
+ }
Original file line number Diff line number Diff line change
1
+ variable "name" {
2
+ description = " Channel config name"
3
+ type = string
4
+ }
5
+
6
+ variable "id" {
7
+ description = " Channel config ID"
8
+ type = string
9
+ }
10
+
11
+ variable "description" {
12
+ description = " Channel config description"
13
+ type = string
14
+ default = " "
15
+ }
16
+
17
+ variable "webhook_url" {
18
+ description = " Slack webhook URL"
19
+ type = string
20
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.4"
3
+
4
+ required_providers {
5
+ opensearch = {
6
+ source = " opensearch-project/opensearch"
7
+ version = " >= 2.0"
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ ## Requirements
2
+
3
+ | Name | Version |
4
+ | ------| ---------|
5
+ | <a name =" requirement_terraform " ></a > [ terraform] ( #requirement\_ terraform ) | >= 1.4 |
6
+ | <a name =" requirement_opensearch " ></a > [ opensearch] ( #requirement\_ opensearch ) | >= 2.0 |
7
+
8
+ ## Providers
9
+
10
+ | Name | Version |
11
+ | ------| ---------|
12
+ | <a name =" provider_opensearch " ></a > [ opensearch] ( #provider\_ opensearch ) | >= 2.0 |
13
+
14
+ ## Modules
15
+
16
+ No modules.
17
+
18
+ ## Resources
19
+
20
+ | Name | Type |
21
+ | ------| ------|
22
+ | [ opensearch_monitor.this] ( https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/monitor ) | resource |
23
+
24
+ ## Inputs
25
+
26
+ | Name | Description | Type | Default | Required |
27
+ | ------| -------------| ------| ---------| :--------:|
28
+ | <a name =" input_body " ></a > [ body] ( #input\_ body ) | The monitor document | ` string ` | n/a | yes |
29
+
30
+ ## Outputs
31
+
32
+ | Name | Description |
33
+ | ------| -------------|
34
+ | <a name =" output_id " ></a > [ id] ( #output\_ id ) | The ID of the monitor |
Original file line number Diff line number Diff line change
1
+ resource "opensearch_monitor" "this" {
2
+ body = jsonencode (var. body )
3
+ }
Original file line number Diff line number Diff line change
1
+ output "id" {
2
+ description = " The ID of the monitor"
3
+ value = opensearch_monitor. this . id
4
+ }
Original file line number Diff line number Diff line change
1
+ variable "body" {
2
+ description = " The monitor document in HCL format"
3
+ type = any
4
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.4"
3
+
4
+ required_providers {
5
+ opensearch = {
6
+ source = " opensearch-project/opensearch"
7
+ version = " >= 2.0"
8
+ }
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments