Skip to content

Commit 85dccf8

Browse files
feat: Add the ability to configure cloud logs policies using new input cloud_logs_policies (#209)
1 parent 9f559cf commit 85dccf8

File tree

6 files changed

+118
-7
lines changed

6 files changed

+118
-7
lines changed

solutions/instances/DA-types.md

+59-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# Configuring Event Notification (EN) Instances for Cloud Logging
1+
# Configuring complex inputs for Cloud Automation for Observability
22

3-
An optional input variables in the IBM Cloud [Observability instances deployable architecture](https://cloud.ibm.com/catalog#deployable_architecture) use complex object types. You specify these inputs when you configure deployable architecture.
3+
Several optional input variables in the IBM Cloud [Observability instances deployable architecture](https://cloud.ibm.com/catalog#deployable_architecture) use complex object types. You specify these inputs when you configure deployable architecture.
4+
5+
* Cloud Logs Event Notification Instances (`cloud_logs_existing_en_instances`)
6+
* Cloud Logs policies (`cloud_logs_policies`)
47

5-
- [Cloud Logs Event Notification Instances](#cloud_logs_existing_en_instances) (`cloud_logs_existing_en_instances`)
68

79
## Cloud Logs Event Notification Instances <a name="cloud_logs_existing_en_instances"></a>
810

911
The `cloud_logs_existing_en_instances` input variable allows you to provide a list of existing Event Notification (EN) instances that will be integrated with the Cloud Logging service. For each EN instance, you need to specify its CRN (Cloud Resource Name). You can also optionally configure a integration name and control whether to skip the creation of an authentication policy for the instance.
1012

1113
- Variable name: `cloud_logs_existing_en_instances`.
12-
- Type: A list of objects. Each object represents an EN instance with the following attributes:
14+
- Type: A list of objects. Each object represents an EN instance.
15+
- Default value: An empty list (`[]`).
16+
17+
### Options for cloud_logs_existing_en_instances
18+
1319
- `instance_crn` (required): The Cloud Resource Name (CRN) of the Event Notification instance.
1420
- `integration_name` (optional): The name of the Event Notification integration that gets created. If a prefix input variable is passed, it is prefixed to the value in the `<prefix>-value` format. Defaults to `"cloud-logs-en-integration"`.
1521
- `skip_en_auth_policy` (optional): A boolean flag to determine whether to skip the creation of an authentication policy that allows Cloud Logs 'Event Source Manager' role access in the existing event notification instance. Defaults to `false`.
16-
- Default value: An empty list (`[]`).
17-
1822

1923
### Example Event Notification Instance Configuration
2024

@@ -35,3 +39,52 @@ cloud_logs_existing_en_instances = [
3539
In this example:
3640
- The first EN instance has a integration name `"custom-logging-en-integration"` and skips the authentication policy.
3741
- The second EN instance uses the default integration name and includes the authentication policy.
42+
43+
## Cloud Logs Policies <a name="cloud_logs_policies"></a>
44+
45+
The `cloud_logs_policies` input variable allows you to provide a list of policies that will be configured in the Cloud Logs service. Refer [here](https://cloud.ibm.com/docs/cloud-logs?topic=cloud-logs-tco-optimizer) for more information.
46+
47+
- Variable name: `cloud_logs_policies`.
48+
- Type: A list of objects. Each object represents a policy.
49+
- Default value: An empty list (`[]`).
50+
51+
### Options for cloud_logs_policies
52+
53+
- `logs_policy_name` (required): The unique policy name.
54+
- `logs_policy_description` (optional): The description of the policy to create.
55+
- `logs_policy_priority` (required): The priority to determine the pipeline for the logs. Allowed values are: type_unspecified, type_block, type_low, type_medium, type_high. High (priority value) sent to 'Priority insights' (TCO pipleine), Medium to 'Analyze and alert', Low to 'Store and search', Blocked are not sent to any pipeline.
56+
- `application_rule` (optional): The rules to include in the policy configuration for matching applications.
57+
- `subsystem_rule` (optional): The subsystem rules to include in the policy configuration for matching applications.
58+
- `log_rules` (required): The log severities to include in the policy configuration.
59+
- `archive_retention` (optional): Define archive retention.
60+
61+
### Example cloud_logs_policies
62+
63+
```hcl
64+
cloud_logs_policies = [
65+
{
66+
logs_policy_name = "logs-policy-1"
67+
logs_policy_description = "Send info and debug logs of the application (name starts with `test-system-app`) and the subsytem (name starts with `test-sub-system`) logs to Store nad search pipeline"
68+
logs_policy_priority = "type_low"
69+
application_rule = [{
70+
name = "test-system-app"
71+
rule_type_id = "start_with"
72+
}]
73+
log_rules = [{
74+
severities = ["info", "debug"]
75+
}]
76+
subsystem_rule = [{
77+
name = "test-sub-system"
78+
rule_type_id = "start_with"
79+
}]
80+
},
81+
{
82+
logs_policy_name = "logs-policy-2"
83+
logs_policy_description = "Send error logs of all applications and all subsystems to Analyze and Alert pipeline"
84+
logs_policy_priority = "type_medium"
85+
log_rules = [{
86+
severities = ["error"]
87+
}]
88+
}
89+
]
90+
```

solutions/instances/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This deployable architecture creates observability instances in IBM Cloud and su
1313
* A KMS-encrypted Object Storage bucket for Cloud Logs metrics, if one is not passed in.
1414
* An Activity Tracker event route to an Object Storage bucket and Cloud Logs target.
1515
* An option to integrate Cloud Logs with existing event notification instance.
16+
* An option to configure Cloud logs policies (TCO Optimizer).
1617

1718
![observability-instances-deployable-architecture](../../reference-architecture/deployable-architecture-observability-instances.svg)
1819

solutions/instances/main.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ module "en_crn_parser" {
216216
module "observability_instance" {
217217
depends_on = [time_sleep.wait_for_atracker_cos_authorization_policy]
218218
source = "terraform-ibm-modules/observability-instances/ibm"
219-
version = "3.0.2"
219+
version = "3.3.1"
220220
region = var.region
221221
resource_group_id = module.resource_group.resource_group_id
222222

@@ -237,6 +237,7 @@ module "observability_instance" {
237237
cloud_logs_tags = var.cloud_logs_tags
238238
cloud_logs_service_endpoints = "public-and-private"
239239
cloud_logs_retention_period = var.cloud_logs_retention_period
240+
cloud_logs_policies = var.cloud_logs_policies
240241
cloud_logs_data_storage = var.cloud_logs_provision ? {
241242
logs_data = {
242243
enabled = true

solutions/instances/outputs.tf

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ output "cloud_logs_name" {
2929
description = "The name of the provisioned Cloud Logs instance."
3030
}
3131

32+
## Cloud logs policies
33+
output "logs_policies_details" {
34+
value = length(var.cloud_logs_policies) > 0 ? module.observability_instance.logs_policies_details : null
35+
description = "The details of the Cloud logs policies created."
36+
}
37+
3238
## Cloud Monitoring
3339
output "cloud_monitoring_name" {
3440
value = var.cloud_monitoring_provision ? module.observability_instance.cloud_monitoring_name : null

solutions/instances/variables.tf

+28
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,34 @@ variable "manage_log_archive_cos_bucket" {
222222
description = "Log Analysis has been deprecated, and can no longer be deployed wuth this solution, however you can continue to manage the COS bucket that may have been in older versions for Log Analysis log archiving by setting this input to true."
223223
}
224224

225+
########################################################################
226+
# Cloud Logs Policies - TCO Optimizer
227+
#########################################################################
228+
229+
variable "cloud_logs_policies" {
230+
type = list(object({
231+
logs_policy_name = string
232+
logs_policy_description = optional(string, null)
233+
logs_policy_priority = string
234+
application_rule = optional(list(object({
235+
name = string
236+
rule_type_id = optional(string, "unspecified")
237+
})))
238+
subsystem_rule = optional(list(object({
239+
name = string
240+
rule_type_id = optional(string, "unspecified")
241+
})))
242+
log_rules = optional(list(object({
243+
severities = list(string)
244+
})))
245+
archive_retention = optional(list(object({
246+
id = string
247+
})))
248+
}))
249+
description = "Configuration of Cloud Logs policies. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-observability-da/tree/main/solutions/standard/DA-types.md#cloud_logs_policies)."
250+
default = []
251+
}
252+
225253
##############################################################################
226254
# Activity Tracker Event Routing Variables
227255
##############################################################################

tests/pr_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ func TestRunUpgradeSolutionInstances(t *testing.T) {
117117
"management_endpoint_type_for_bucket": "public",
118118
"enable_platform_logs": "false",
119119
"enable_platform_metrics": "false",
120+
"cloud_logs_policies": []map[string]interface{}{
121+
{
122+
"logs_policy_name": "upg-test-policy",
123+
"logs_policy_priority": "type_low",
124+
"log_rules": []map[string]interface{}{
125+
{
126+
"severities": []string{"info", "debug"},
127+
},
128+
},
129+
},
130+
},
120131
}
121132

122133
output, err := options.RunTestUpgrade()
@@ -277,6 +288,17 @@ func TestRunExistingResourcesInstances(t *testing.T) {
277288
"management_endpoint_type_for_bucket": "public",
278289
"enable_platform_metrics": "false",
279290
"enable_platform_logs": "false",
291+
"cloud_logs_policies": []map[string]interface{}{
292+
{
293+
"logs_policy_name": "test-policy",
294+
"logs_policy_priority": "type_low",
295+
"log_rules": []map[string]interface{}{
296+
{
297+
"severities": []string{"info"},
298+
},
299+
},
300+
},
301+
},
280302
},
281303
})
282304

0 commit comments

Comments
 (0)