|
| 1 | +# Observe Lambda cloudwatch metrics configuration |
| 2 | + |
| 3 | +This module configures the Observe lambda to periodically pull metrics from AWS |
| 4 | +Cloudwatch. While configured in a similar manner to the "snapshot" module, the |
| 5 | +cloudwatch metrics functionality is distinct in that it does not simply logs |
| 6 | +responses to raw API calls. The lambda takes a simplified configuration for |
| 7 | +querying sets of metrics, and produces a list of metrics more readily consumed |
| 8 | +than the raw API response from AWS. |
| 9 | + |
| 10 | +This module sets up an event rule in EventBridge which triggers the Observe |
| 11 | +Lambda periodically. Additionally, the module will add a policy to the existing |
| 12 | +lambda to ensure that all requested endpoints are accessible. |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +```hcl |
| 17 | +module "observe_lambda" { |
| 18 | + source = "observeinc/lambda/aws" |
| 19 | + observe_customer = var.observe_customer |
| 20 | + observe_token = var.observe_token |
| 21 | + observe_domain = var.observe_domain |
| 22 | + name = random_pet.run.id |
| 23 | +} |
| 24 | +
|
| 25 | +module "cloudwatch_metrics" { |
| 26 | + source = "observeinc/lambda/aws//modules/cloudwatch_metrics" |
| 27 | + lambda = module.observe_lambda |
| 28 | +
|
| 29 | + filters = [ |
| 30 | + { |
| 31 | + namespace = "AWS/RDS" |
| 32 | + } |
| 33 | + ] |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 38 | +## Requirements |
| 39 | + |
| 40 | +| Name | Version | |
| 41 | +|------|---------| |
| 42 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 | |
| 43 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.68 | |
| 44 | + |
| 45 | +## Providers |
| 46 | + |
| 47 | +| Name | Version | |
| 48 | +|------|---------| |
| 49 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.68 | |
| 50 | + |
| 51 | +## Modules |
| 52 | + |
| 53 | +No modules. |
| 54 | + |
| 55 | +## Resources |
| 56 | + |
| 57 | +| Name | Type | |
| 58 | +|------|------| |
| 59 | +| [aws_cloudwatch_event_rule.trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | |
| 60 | +| [aws_cloudwatch_event_target.target](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource | |
| 61 | +| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | |
| 62 | +| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | |
| 63 | +| [aws_lambda_permission.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | |
| 64 | + |
| 65 | +## Inputs |
| 66 | + |
| 67 | +| Name | Description | Type | Default | Required | |
| 68 | +|------|-------------|------|---------|:--------:| |
| 69 | +| <a name="input_delay"></a> [delay](#input\_delay) | Collection delay in seconds. This delay accounts for the lag in metrics availability via Cloudwatch API. | `number` | `300` | no | |
| 70 | +| <a name="input_eventbridge_name_prefix"></a> [eventbridge\_name\_prefix](#input\_eventbridge\_name\_prefix) | Prefix used for eventbridge rule | `string` | `"observe-lambda-metrics-"` | no | |
| 71 | +| <a name="input_eventbridge_schedule_event_bus_name"></a> [eventbridge\_schedule\_event\_bus\_name](#input\_eventbridge\_schedule\_event\_bus\_name) | Event Bus for EventBridge scheduled events | `string` | `"default"` | no | |
| 72 | +| <a name="input_filters"></a> [filters](#input\_filters) | List of filters. | <pre>list(object({<br> namespace = string<br> list_mode = optional(string)<br> metric_names = optional(list(string))<br> dimensions = optional(list(object({<br> name = string<br> value = optional(string)<br> })))<br> }))</pre> | n/a | yes | |
| 73 | +| <a name="input_iam_name_prefix"></a> [iam\_name\_prefix](#input\_iam\_name\_prefix) | Prefix used for all created IAM roles and policies | `string` | `""` | no | |
| 74 | +| <a name="input_interval"></a> [interval](#input\_interval) | Interval in seconds between collection runs. Use a multiple of period to avoid gaps. | `number` | `300` | no | |
| 75 | +| <a name="input_lambda"></a> [lambda](#input\_lambda) | Observe Lambda module | <pre>object({<br> lambda_function = object({<br> arn = string<br> role = string<br> })<br> })</pre> | n/a | yes | |
| 76 | +| <a name="input_period"></a> [period](#input\_period) | Period in seconds between metric data points. Must be a multiple of 60. | `number` | `60` | no | |
| 77 | +| <a name="input_statement_id_prefix"></a> [statement\_id\_prefix](#input\_statement\_id\_prefix) | Prefix used for Lambda permission statement ID | `string` | `""` | no | |
| 78 | + |
| 79 | +## Outputs |
| 80 | + |
| 81 | +No outputs. |
| 82 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +Apache 2 Licensed. See LICENSE for full details. |
0 commit comments