Skip to content

Commit 523a9c9

Browse files
authored
Adding APM logging (#19)
* feat: Adding APM logging * fix: file headers
1 parent 968491b commit 523a9c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+337
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Learn how to [contribute][contributing].
3636

3737
## License
3838

39-
Copyright (c) 2019, 2021 Oracle and/or its associates.
39+
Copyright (c) 2021 Oracle and/or its associates.
4040

4141
Licensed under the [Universal Permissive License 1.0][license] as shown at
4242
[https://oss.oracle.com/licenses/upl][canonical_license].

examples/lb_log/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
#Copyright (c) 2021, 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
terraform {
25
required_version = ">= 1.0.0"
36
required_providers {
47
oci = {
5-
source = "hashicorp/oci"
6-
version = ">=4.38.0"
8+
source = "oracle/oci"
9+
version = ">= 4.67.3"
710
}
811
}
912
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
compartment_id = ""
1+
#Copyright (c) 2021, 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+
compartment_id = "<compartment OCID>"
25
lbname = ""

examples/lb_log/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "compartment_id" {
25
type = string
36
description = "compartment id where to create the resources"

examples/objectstorage_log/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
#Copyright (c) 2021, 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
terraform {
25
required_version = ">= 1.0.0"
36
required_providers {
47
oci = {
5-
source = "hashicorp/oci"
6-
version = ">=4.38.0"
8+
source = "oracle/oci"
9+
version = ">= 4.67.3"
710
}
811
}
912
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
bucket_name = "testbucket"
25
bucket_namespace = ""
36
compartment_id = ""

examples/objectstorage_log/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "compartment_id" {
25
type = string
36
description = "compartment id where to create the resources"

examples/vcnflow_log/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
#Copyright (c) 2021, 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
terraform {
25
required_version = ">= 1.0.0"
36
required_providers {
47
oci = {
5-
source = "hashicorp/oci"
6-
version = ">=4.38.0"
8+
source = "oracle/oci"
9+
version = ">= 4.67.3"
710
}
811
}
912
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
#Copyright (c) 2021, 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
compartment_id = ""

examples/vcnflow_log/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "compartment_id" {
25
type = string
36
description = "compartment id where to create the resources"

examples/vcnflow_log/vcn/vcn.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
resource "oci_core_vcn" "test_vcn" {
25

36
compartment_id = var.compartment_id

locals.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
#Copyright (c) 2021, 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
locals {
25
apigwlogdef = { for k, v in var.service_logdef : k => v if v.service == "apigateway" }
36
apigwloggroup = [for k, v in var.service_logdef : v.loggroup if v.service == "apigateway"]
47

8+
apmlogdef = { for k, v in var.service_logdef : k => v if v.service == "apm" }
9+
apmloggroup = [for k, v in var.service_logdef : v.loggroup if v.service == "apm"]
10+
511
devopslogdef = { for k, v in var.service_logdef : k => v if v.service == "devops" }
612
devopsloggroup = [for k, v in var.service_logdef : v.loggroup if v.service == "devops"]
713

main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
#APIGateway loggroup resource
25
resource "oci_logging_log_group" "apigwloggroup" {
36

@@ -10,6 +13,18 @@ resource "oci_logging_log_group" "apigwloggroup" {
1013

1114
}
1215

16+
#APM loggroup resource
17+
resource "oci_logging_log_group" "apmloggroup" {
18+
19+
for_each = toset(local.apmloggroup)
20+
21+
compartment_id = var.compartment_id
22+
description = "APM Loggroup"
23+
display_name = var.label_prefix == "none" ? each.value : format("%s-%s", var.label_prefix, each.value)
24+
freeform_tags = var.loggroup_tags
25+
26+
}
27+
1328
#Devops loggroup
1429
resource "oci_logging_log_group" "devopsloggroup" {
1530

@@ -180,6 +195,18 @@ module "apigwlog" {
180195

181196
}
182197

198+
module "apmlog" {
199+
source = "./modules/apm"
200+
compartment_id = var.compartment_id
201+
label_prefix = var.label_prefix
202+
logdefinition = local.apmlogdef
203+
log_retention_duration = var.log_retention_duration
204+
loggroup = oci_logging_log_group.apmloggroup
205+
206+
count = length(local.apmlogdef) >= 1 ? 1 : 0
207+
208+
}
209+
183210
module "customlog" {
184211
source = "./modules/custom"
185212
compartment_id = var.compartment_id

modules/apigateway/apigwlog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
data "oci_apigateway_deployments" "apigw_deployments" {
25

36
for_each = var.logdefinition

modules/apigateway/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
output "apigw_accesslogid" {
25
value = { for v in oci_logging_log.apigw_access_log : v.display_name => v.id }
36
}

modules/apigateway/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "label_prefix" {
25
default = "none"
36
description = "A string that will be prepended to log resources."

modules/apigateway/versions.tf

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
terraform {
25
required_providers {
36
oci = {

modules/apm/apmlog.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
data "oci_apm_apm_domains" "apm_domains" {
5+
for_each = var.logdefinition
6+
compartment_id = var.compartment_id
7+
8+
display_name = each.value.resource
9+
state = "ACTIVE"
10+
}
11+
12+
resource "oci_logging_log" "apm_log" {
13+
14+
15+
for_each = var.logdefinition
16+
17+
display_name = var.label_prefix == "none" ? each.key : format("%s-%s", var.label_prefix, each.key)
18+
log_group_id = var.loggroup[each.value.loggroup].id
19+
log_type = "SERVICE"
20+
configuration {
21+
source {
22+
category = "dropped-data"
23+
resource = data.oci_apm_apm_domains.apm_domains[each.key].apm_domains[0].id
24+
service = "apm"
25+
source_type = "OCISERVICE"
26+
}
27+
}
28+
29+
is_enabled = lookup(each.value, "enable", true)
30+
retention_duration = var.log_retention_duration
31+
32+
}

modules/apm/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
output "apm_logid" {
5+
value = { for v in oci_logging_log.apm_log : v.display_name => v.id }
6+
}
7+
8+
output "apm_loggroupid" {
9+
value = { for k, v in var.loggroup : v.display_name => v.id }
10+
}

modules/apm/variables.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 "label_prefix" {
5+
default = "none"
6+
description = "A string that will be prepended to log resources."
7+
type = string
8+
}
9+
variable "logdefinition" {
10+
type = map(any)
11+
description = "Log definition"
12+
}
13+
variable "log_retention_duration" {
14+
type = string
15+
description = "Duration to retain logs"
16+
}
17+
18+
variable "compartment_id" {
19+
type = string
20+
description = "Compartment ID where the resources will be created"
21+
}
22+
23+
variable "loggroup" {
24+
type = map(any)
25+
description = "Log Group"
26+
}

modules/apm/versions.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
terraform {
5+
required_providers {
6+
oci = {
7+
source = "oracle/oci"
8+
version = ">= 4.67.3"
9+
}
10+
}
11+
required_version = ">= 1.0.0"
12+
}

modules/custom/customlog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
locals {
25
logdef = { for k, v in var.linux_logdef : k => v }
36
loggroup = [for k, v in var.linux_logdef : v.loggroup]

modules/custom/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
output "linuxlogid" {
25
value = { for v in oci_logging_log.linux_log : v.display_name => v.id }
36
}

modules/custom/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "label_prefix" {
25
default = "none"
36
description = "A string that will be prepended to log resources."

modules/custom/versions.tf

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
terraform {
25
required_providers {
36
oci = {

modules/devops/devopslog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
data "oci_devops_projects" "devops_projects" {
25
for_each = var.logdefinition
36
compartment_id = var.compartment_id

modules/devops/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
output "devops_logid" {
25
value = { for v in oci_logging_log.devops_log : v.display_name => v.id }
36
}

modules/devops/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "label_prefix" {
25
default = "none"
36
description = "A string that will be prepended to log resources."

modules/devops/versions.tf

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
terraform {
25
required_providers {
36
oci = {

modules/emaildelivery/emaillog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
data "oci_email_email_domains" "email_domains" {
25
for_each = var.logdefinition
36
compartment_id = var.compartment_id

modules/emaildelivery/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
output "emaillogaccept_id" {
25
value = { for v in oci_logging_log.email_outboundaccepted_log : v.display_name => v.id }
36
}

modules/emaildelivery/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "label_prefix" {
25
default = "none"
36
description = "A string that will be prepended to log resources."

modules/emaildelivery/versions.tf

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
terraform {
25
required_providers {
36
oci = {

modules/event/eventlog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
data "oci_events_rules" "event_rules" {
25
for_each = var.logdefinition
36
compartment_id = var.compartment_id

modules/event/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
output "event_logid" {
25
value = { for v in oci_logging_log.ruleexecution_log : v.display_name => v.id }
36
}

modules/event/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
variable "label_prefix" {
25
default = "none"
36
description = "A string that will be prepended to log resources."

modules/event/versions.tf

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
terraform {
25
required_providers {
36
oci = {

modules/function/functionlog.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Copyright (c) 2021, 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
data "oci_functions_applications" "func_apps" {
25

36
for_each = var.logdefinition

0 commit comments

Comments
 (0)