Skip to content

Commit cb894fa

Browse files
authored
Doc and examples updated (#2)
* doc updated Signed-off-by: Karthic Ravindran <[email protected]> * updated README Signed-off-by: Karthic Ravindran <[email protected]> * updated README in alarm module Signed-off-by: Karthic Ravindran <[email protected]> * updated alarm module Signed-off-by: Karthic Ravindran <[email protected]> * updated alarm README Signed-off-by: Karthic Ravindran <[email protected]> --------- Signed-off-by: Karthic Ravindran <[email protected]>
1 parent 5f01aad commit cb894fa

19 files changed

+403
-26
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
# Oracle Cloud Infrastructure Terraform Module for Observability
22

3-
*This module is for creating resources related to Observability in Oracle Cloud Infrastructure*
3+
*This module is for creating resources related to [Observability](https://www.oracle.com/in/manageability/) in Oracle Cloud Infrastructure*
44

5-
## Installation
6-
7-
*Provide detailed step-by-step installation instructions*
5+
## Pre-requisites:
86

7+
- git is installed.
8+
- Terraform 1.3.0 or higher version is installed.
9+
- [Required keys](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm) are availabe for authentication
910
## Documentation
10-
11-
*Developer-oriented documentation can be published on GitHub, but all product documentation must be published on <https://docs.oracle.com>*
12-
13-
## Examples
14-
15-
*Describe any included examples or provide a link to a demo/tutorial*
16-
17-
## Help
18-
19-
*Inform users on where to get help or how to receive official support from Oracle (if applicable)*
11+
Please refer to the [examples](https://github.com/oracle-terraform-modules/terraform-oci-oandm/tree/main/examples) on how to use each submodule.
12+
Below are some reference document to understand the service related to the modules
13+
[Alarm](https://docs.oracle.com/en-us/iaas/Content/Monitoring/Tasks/managingalarms.htm)
14+
[ServiceConnector](https://docs.oracle.com/en-us/iaas/Content/service-connector-hub/overview.htm)
2015

2116
## Contributing
2217

examples/alarm/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Simple Alarm creation
2+
3+
This example is to create a simple alarm with notification topic.
4+
Rename the provider.tf.example to provider.tf and provide the required values
5+
6+
Local values are defined to test it quickly.
7+
If you like to create multiple alarms with a topic then rename the terraform.tfvars.example to terraform.tfvars.
8+
9+
Run the terraform commands to execute
10+
```console
11+
terraform init
12+
terraform plan
13+
terraform apply
14+
```

examples/alarm/main.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
14
module "alarm" {
2-
source = "./modules/alarm"
5+
source = "../../modules/alarm"
36
alarm_def = local.alarm_def
47
compartment_ocid = local.compartment_ocid
58
notification = local.notification
@@ -22,10 +25,11 @@ locals {
2225
}
2326
}
2427
alarm_def = {
25-
"testdelete" = {
26-
destination = "demotopic"
27-
namespace = "oci_computeagent"
28-
query = "CpuUtilization[1m].mean() > 70"
28+
demoalarm = {
29+
destination = "demotopic"
30+
display_name = "demoalarm"
31+
namespace = "oci_computeagent"
32+
query = "CpuUtilization[1m].mean() > 70"
2933
}
3034
}
3135
}

examples/alarm/provider.tf.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
14
provider "oci" {
25
region = "<region where alarm,notification to be created>"
36
fingerprint = ""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
5+
compartment_ocid = "<compartment where topic and alarm to be created>"
6+
alarm_def = {
7+
alarm1 = {
8+
display_name = "alarm1"
9+
destination = "demotopic"
10+
namespace = "oci_computeagent"
11+
query = "CpuUtilization[1m].mean() > 70"
12+
}
13+
alarm2 = {
14+
display_name = "alarm2"
15+
destination = "demotopic"
16+
namespace = "oci_computeagent"
17+
query = "CpuUtilization[1m].mean() > 70"
18+
severity = "WARNING"
19+
body = "CPU is greater than 70 please follow the runbook"
20+
}
21+
}
22+
notification = {
23+
demotopic = {
24+
subscription = {
25+
sub1 = {
26+
protocol = "EMAIL"
27+
endpoint = "<email address>"
28+
}
29+
sub2 = {
30+
protocol = "SMS"
31+
endpoint = "<phonenumber>"
32+
}
33+
}
34+
}
35+
}

examples/alarm/variables.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
variable "compartment_ocid" {
5+
description = "Compartment OCID"
6+
type = string
7+
}
8+
9+
10+
variable "alarm_def" {
11+
description = "OCI Alarm definition"
12+
type = map(object({
13+
destination = string
14+
display_name = string
15+
severity = optional(string, "CRITICAL")
16+
query = string
17+
is_enabled = optional(bool, true)
18+
namespace = string
19+
metric_compartment_id = optional(string)
20+
repeat_notification_duration = optional(string, "PT5M")
21+
trigger = optional(string, "PT5M")
22+
suppression_from_time = optional(string)
23+
suppression_till_time = optional(string)
24+
message_format = optional(string, "RAW")
25+
body = optional(string, null)
26+
freeform_tags = optional(map(string))
27+
defined_tags = optional(map(string))
28+
}))
29+
}
30+
31+
variable "notification" {
32+
description = "Notification Topic and Subscription"
33+
type = map(object({
34+
description = optional(string)
35+
create_topic = optional(bool, true)
36+
defined_tags = optional(map(string))
37+
freeform_tags = optional(map(string))
38+
subscription = optional(map(object({
39+
endpoint = string
40+
protocol = string
41+
})))
42+
}))
43+
}
44+
45+
variable "label_prefix" {
46+
default = "none"
47+
description = "Prefix to be added to the resources"
48+
type = string
49+
}

examples/multiplealarm/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Multiple Alarm creation
2+
3+
This example is to create multiple alarm with notification topic based on csv file.
4+
Rename the provider.tf.example to provider.tf and provide the required values
5+
6+
This example does not create any subscription for the topic.
7+
8+
In the csv for the column named create_topic specify *true* if the topic has to be created and *false* if you want to use existing topic.
9+
10+
Run the terraform commands to execute
11+
```console
12+
terraform init
13+
terraform plan
14+
terraform apply
15+
```

examples/multiplealarm/alarm.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
display_name,namespace,query,destination,create_topic,severity
2+
alarm1,oci_computeagent,CpuUtilization[1m].mean() > 80,demo1,true,
3+
alarm2,oci_computeagent,CpuUtilization[1m].mean() > 50,demotopic,false,WARNING
4+
alarm3,oci_computeagent,MemoryUtilization[1m].mean() > 80,demo1,true,

examples/multiplealarm/main.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
module "multiplealarm" {
5+
source = "../../modules/alarm"
6+
alarm_def = local.alarm_def_map
7+
compartment_ocid = local.compartment_ocid
8+
notification = local.notification
9+
10+
}
11+
12+
locals {
13+
compartment_ocid = "<compartment_id>"
14+
alarm_def = csvdecode(file("./alarm.csv"))
15+
alarm_def_map = { for alarm in local.alarm_def : alarm.display_name => alarm }
16+
topicmergelist = distinct([for alarm in local.alarm_def_map : { create_topic = alarm.create_topic, destination = alarm.destination }])
17+
notification = { for topic in local.topicmergelist : topic.destination => { create_topic = topic.create_topic } }
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
provider "oci" {
5+
region = "<region where alarm,notification to be created>"
6+
fingerprint = ""
7+
private_key_path = ""
8+
9+
tenancy_ocid = ""
10+
user_ocid = ""
11+
12+
}
13+
14+
terraform {
15+
required_providers {
16+
oci = {
17+
source = "oracle/oci"
18+
version = ">= 4.67.3"
19+
}
20+
}
21+
required_version = ">= 1.3.0"
22+
}

examples/multiplealarm/variables.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
variable "compartment_ocid" {
5+
description = "Compartment OCID"
6+
type = string
7+
}
8+
9+
10+
variable "alarm_def" {
11+
description = "OCI Alarm definition"
12+
type = map(object({
13+
destination = string
14+
display_name = string
15+
severity = optional(string, "CRITICAL")
16+
query = string
17+
is_enabled = optional(bool, true)
18+
namespace = string
19+
metric_compartment_id = optional(string)
20+
repeat_notification_duration = optional(string, "PT5M")
21+
trigger = optional(string, "PT5M")
22+
suppression_from_time = optional(string)
23+
suppression_till_time = optional(string)
24+
message_format = optional(string, "RAW")
25+
body = optional(string, null)
26+
freeform_tags = optional(map(string))
27+
defined_tags = optional(map(string))
28+
}))
29+
}
30+
31+
variable "notification" {
32+
description = "Notification Topic and Subscription"
33+
type = map(object({
34+
description = optional(string)
35+
create_topic = optional(bool, true)
36+
defined_tags = optional(map(string))
37+
freeform_tags = optional(map(string))
38+
subscription = optional(map(object({
39+
endpoint = string
40+
protocol = string
41+
})))
42+
}))
43+
}
44+
45+
variable "label_prefix" {
46+
default = "none"
47+
description = "Prefix to be added to the resources"
48+
type = string
49+
}

examples/serviceconnector/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Service Connector creation
2+
3+
This example is to create a service connector with source as streaming and target as object storage.
4+
Rename the provider.tf.example to provider.tf and provide the required values
5+
6+
Local values are defined to test it quickly.
7+
If you like to create multiple service connectors then rename the terraform.tfvars.example to terraform.tfvars and provide the required values
8+
9+
Supported values for sch_source in variable service_connector_def is
10+
- streaming
11+
- logging
12+
- monitoring
13+
14+
Supported values for sch_target in variable service_connector_def is
15+
- loggingAnalytics
16+
- objectstorage
17+
- functions
18+
- streaming
19+
- notifications
20+
21+
If the dynamic group is created manually then the variable *dynamic_group* can be empty map `{}` which is the default value
22+
23+
Run the terraform commands to execute
24+
```console
25+
terraform init
26+
terraform plan
27+
terraform apply
28+
```

examples/serviceconnector/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
14
module "svc" {
2-
source = "./modules/serviceconnector"
5+
source = "../../modules/serviceconnector"
36
service_connector_def = local.service_connector_def
47
policy_compartment_id = local.policy_compartment_id
58
dynamic_group = local.dynamic_group

examples/serviceconnector/provider.tf.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
14
provider "oci" {
25
region = "<region where service connector to be created>"
36
fingerprint = ""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
tenancy_ocid = "<tenancy_ocid>"
5+
dynamic_group = {
6+
sch_dg = { compartment_id = "<service connector compartment id>" }
7+
}
8+
policy_compartment_id = "<policy compartment>" #if not set policy will be created default in root compartment
9+
service_connector_def = { sch_stream_storage = {
10+
compartment_id = "<service connector compartment id>"
11+
#If policy needs to be created set the below two values. By default its set to false to not create policy
12+
#Set create_policy to true
13+
#set dynamic group name with respect to service connector compartment
14+
create_policy = true
15+
dynamic_group_name = sch_dg
16+
17+
sch_source = "streaming"
18+
sch_target = "objectstorage"
19+
display_name = "sch_stream_storage"
20+
21+
stream_id = "<existing stream ocid>"
22+
target = {
23+
bucket = "<bucket name>"
24+
}
25+
}
26+
sch_logging_LA = {
27+
compartment_id = "<service connector compartment id>"
28+
#If policy needs to be created set the below two values. By default its set to false to not create policy
29+
#set dynamicgroup name with respect to service connector compartment
30+
create_policy = true
31+
dynamic_group_name = sch_dg
32+
33+
sch_source = "logging"
34+
sch_target = "loggingAnalytics"
35+
display_name = "sch_logging_LA"
36+
37+
log_source = [{
38+
#specify compartment_id if its different from service connector compartment
39+
compartment_id = "<compartment_id>"
40+
log_group_id = "<ocilogging_loggroup_id>"
41+
42+
}]
43+
44+
target = {
45+
log_group_id = "<loggingAnalytics_loggroup_id>"
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)