From a235c1c20f7e61986134375a0b996e1e0ab9b92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Taveira=20Ara=C3=BAjo?= Date: Thu, 18 Apr 2024 11:24:16 -0700 Subject: [PATCH] feat(forwarder): add `debug_endpoint` parameter --- modules/forwarder/README.md | 1 + modules/forwarder/lambda.tf | 10 ++++++---- modules/forwarder/variables.tf | 7 +++++++ modules/logwriter/README.md | 2 +- modules/logwriter/variables.tf | 4 ++-- modules/stack/README.md | 2 +- modules/stack/forwarder.tf | 1 + modules/stack/variables.tf | 2 +- modules/subscriber/README.md | 2 +- modules/subscriber/lambda.tf | 3 ++- modules/subscriber/variables.tf | 4 ++-- 11 files changed, 25 insertions(+), 13 deletions(-) diff --git a/modules/forwarder/README.md b/modules/forwarder/README.md index dc2d4e5..fabebae 100644 --- a/modules/forwarder/README.md +++ b/modules/forwarder/README.md @@ -100,6 +100,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [content\_type\_overrides](#input\_content\_type\_overrides) | A list of key value pairs. The key is a regular expression which is
applied to the S3 source (/) of forwarded files. The value
is the content type to set for matching files. For example,
`\.json$=application/x-ndjson` would forward all files ending in `.json`
as newline delimited JSON |
list(object({
pattern = string
content_type = string
}))
| `[]` | no | +| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for the lambda function. | `string` | `""` | no | | [destination](#input\_destination) | Destination filedrop |
object({
arn = string
bucket = string
prefix = string
})
| n/a | yes | | [lambda\_env\_vars](#input\_lambda\_env\_vars) | Environment variables to be passed into lambda. | `map(string)` | `{}` | no | | [lambda\_memory\_size](#input\_lambda\_memory\_size) | Memory size for lambda function. | `number` | `128` | no | diff --git a/modules/forwarder/lambda.tf b/modules/forwarder/lambda.tf index 0d0386b..d8f5fb3 100644 --- a/modules/forwarder/lambda.tf +++ b/modules/forwarder/lambda.tf @@ -11,10 +11,12 @@ resource "aws_lambda_function" "this" { environment { variables = merge({ - DESTINATION_URI = "s3://${var.destination.bucket}/${var.destination.prefix}" - MAX_FILE_SIZE = var.max_file_size - CONTENT_TYPE_OVERRIDES = join(",", [for o in var.content_type_overrides : "${o["pattern"]}=${o["content_type"]}"]) - SOURCE_BUCKET_NAMES = join(",", var.source_bucket_names) + DESTINATION_URI = "s3://${var.destination.bucket}/${var.destination.prefix}" + MAX_FILE_SIZE = var.max_file_size + CONTENT_TYPE_OVERRIDES = join(",", [for o in var.content_type_overrides : "${o["pattern"]}=${o["content_type"]}"]) + SOURCE_BUCKET_NAMES = join(",", var.source_bucket_names) + OTEL_EXPORTER_OTLP_ENDPOINT = var.debug_endpoint + OTEL_TRACES_EXPORTER = var.debug_endpoint == "" ? "none" : "otlp" }, var.lambda_env_vars) } } diff --git a/modules/forwarder/variables.tf b/modules/forwarder/variables.tf index 21fbe1c..6839c66 100644 --- a/modules/forwarder/variables.tf +++ b/modules/forwarder/variables.tf @@ -155,3 +155,10 @@ variable "queue_maximum_batching_window_in_seconds" { nullable = false default = 1 } + +variable "debug_endpoint" { + description = "Endpoint to send debugging telemetry to. Sets the OTEL_EXPORTER_OTLP_ENDPOINT environment variable for the lambda function." + type = string + nullable = false + default = "" +} diff --git a/modules/logwriter/README.md b/modules/logwriter/README.md index 3828fb3..99e97ef 100644 --- a/modules/logwriter/README.md +++ b/modules/logwriter/README.md @@ -94,7 +94,7 @@ module "logwriter" { | [bucket\_arn](#input\_bucket\_arn) | S3 Bucket ARN to write log records to. | `string` | n/a | yes | | [buffering\_interval](#input\_buffering\_interval) | Buffer incoming data for the specified period of time, in seconds, before
delivering it to S3. | `number` | `60` | no | | [buffering\_size](#input\_buffering\_size) | Buffer incoming data to the specified size, in MiBs, before delivering it
to S3. | `number` | `1` | no | -| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTL\_ENDPOINT environment variable for the lambda function. | `string` | `null` | no | +| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for the lambda function. | `string` | `null` | no | | [discovery\_rate](#input\_discovery\_rate) | EventBridge rate expression for periodically triggering discovery. If not
set, no eventbridge rules are configured. | `string` | `null` | no | | [filter\_name](#input\_filter\_name) | Subscription filter name. Existing filters that have this name as a prefix
will be removed. | `string` | `null` | no | | [filter\_pattern](#input\_filter\_pattern) | Subscription filter pattern. | `string` | `null` | no | diff --git a/modules/logwriter/variables.tf b/modules/logwriter/variables.tf index d73c82e..b1752d8 100644 --- a/modules/logwriter/variables.tf +++ b/modules/logwriter/variables.tf @@ -124,7 +124,7 @@ variable "lambda_env_vars" { } variable "debug_endpoint" { - description = "Endpoint to send debugging telemetry to. Sets the OTEL_EXPORTER_OTL_ENDPOINT environment variable for the lambda function." + description = "Endpoint to send debugging telemetry to. Sets the OTEL_EXPORTER_OTLP_ENDPOINT environment variable for the lambda function." type = string default = null -} \ No newline at end of file +} diff --git a/modules/stack/README.md b/modules/stack/README.md index 14bf5d4..eee1f5d 100644 --- a/modules/stack/README.md +++ b/modules/stack/README.md @@ -97,7 +97,7 @@ module "collection_stack" { | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [config](#input\_config) | Variables for AWS Config collection. |
object({
include_resource_types = list(string)
exclude_resource_types = optional(list(string))
delivery_frequency = optional(string)
include_global_resource_types = optional(bool)
})
| `null` | no | -| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets OTEL\_EXPORTER\_OTL\_ENDPOINT environment variable for supported lambda functions. | `string` | `null` | no | +| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for supported lambda functions. | `string` | `null` | no | | [destination](#input\_destination) | Destination filedrop |
object({
arn = string
bucket = string
prefix = string
})
| n/a | yes | | [forwarder](#input\_forwarder) | Variables for forwarder module. |
object({
source_bucket_names = optional(list(string), [])
source_topic_arns = optional(list(string), [])
content_type_overrides = optional(list(object({ pattern = string, content_type = string })), [])
max_file_size = optional(number)
lambda_memory_size = optional(number)
lambda_timeout = optional(number)
lambda_env_vars = optional(map(string))
retention_in_days = optional(number)
queue_max_receive_count = optional(number)
queue_delay_seconds = optional(number)
queue_message_retention_seconds = optional(number)
queue_batch_size = optional(number)
queue_maximum_batching_window_in_seconds = optional(number)
})
| `{}` | no | | [logwriter](#input\_logwriter) | Variables for AWS CloudWatch Logs collection. |
object({
log_group_name_patterns = optional(list(string))
log_group_name_prefixes = optional(list(string))
buffering_interval = optional(number)
buffering_size = optional(number)
filter_name = optional(string)
filter_pattern = optional(string)
num_workers = optional(number)
discovery_rate = optional(string, "24 hours")
lambda_memory_size = optional(number)
lambda_timeout = optional(number)
})
| `null` | no | diff --git a/modules/stack/forwarder.tf b/modules/stack/forwarder.tf index 4829447..922e3a1 100644 --- a/modules/stack/forwarder.tf +++ b/modules/stack/forwarder.tf @@ -17,4 +17,5 @@ module "forwarder" { queue_message_retention_seconds = var.forwarder.queue_message_retention_seconds queue_batch_size = var.forwarder.queue_batch_size queue_maximum_batching_window_in_seconds = var.forwarder.queue_maximum_batching_window_in_seconds + debug_endpoint = var.debug_endpoint } diff --git a/modules/stack/variables.tf b/modules/stack/variables.tf index 022ce69..e9fe3c3 100644 --- a/modules/stack/variables.tf +++ b/modules/stack/variables.tf @@ -91,7 +91,7 @@ variable "metricstream" { } variable "debug_endpoint" { - description = "Endpoint to send debugging telemetry to. Sets OTEL_EXPORTER_OTL_ENDPOINT environment variable for supported lambda functions." + description = "Endpoint to send debugging telemetry to. Sets OTEL_EXPORTER_OTLP_ENDPOINT environment variable for supported lambda functions." type = string default = null } diff --git a/modules/subscriber/README.md b/modules/subscriber/README.md index 561deb1..90b4832 100644 --- a/modules/subscriber/README.md +++ b/modules/subscriber/README.md @@ -47,7 +47,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTL\_ENDPOINT environment variable for the lambda function. | `string` | `""` | no | +| [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for the lambda function. | `string` | `""` | no | | [destination\_iam\_arn](#input\_destination\_iam\_arn) | ARN for destination iam policy | `string` | n/a | yes | | [discovery\_rate](#input\_discovery\_rate) | EventBridge scheduler rate expression for periodically triggering discovery. If not set, no scheduler is configured. | `string` | `""` | no | | [filter\_name](#input\_filter\_name) | Subscription filter name. Existing filters that have this name as a prefix will be removed. | `string` | `"observe-logs-subscription"` | no | diff --git a/modules/subscriber/lambda.tf b/modules/subscriber/lambda.tf index 8ab0aee..bdd29da 100644 --- a/modules/subscriber/lambda.tf +++ b/modules/subscriber/lambda.tf @@ -26,6 +26,7 @@ resource "aws_lambda_function" "subscriber" { VERBOSITY = 9 NUM_WORKERS = var.num_workers OTEL_EXPORTER_OTLP_ENDPOINT = var.debug_endpoint + OTEL_TRACES_EXPORTER = var.debug_endpoint == "" ? "none" : "otlp" }, var.lambda_env_vars) } -} \ No newline at end of file +} diff --git a/modules/subscriber/variables.tf b/modules/subscriber/variables.tf index 196c892..8c68f0f 100644 --- a/modules/subscriber/variables.tf +++ b/modules/subscriber/variables.tf @@ -106,8 +106,8 @@ variable "lambda_env_vars" { } variable "debug_endpoint" { - description = "Endpoint to send debugging telemetry to. Sets the OTEL_EXPORTER_OTL_ENDPOINT environment variable for the lambda function." + description = "Endpoint to send debugging telemetry to. Sets the OTEL_EXPORTER_OTLP_ENDPOINT environment variable for the lambda function." type = string nullable = false default = "" -} \ No newline at end of file +}