Skip to content

Commit

Permalink
feat: Add option to specify metric transformation unit (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Duleendra Shashimal <duleendra@bambu.co>
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
  • Loading branch information
3 people committed Jan 3, 2023
1 parent ef8a0aa commit 5116f50
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/log-metric-filter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ No modules.
| <a name="input_metric_transformation_default_value"></a> [metric\_transformation\_default\_value](#input\_metric\_transformation\_default\_value) | The value to emit when a filter pattern does not match a log event. | `string` | `null` | no |
| <a name="input_metric_transformation_name"></a> [metric\_transformation\_name](#input\_metric\_transformation\_name) | The name of the CloudWatch metric to which the monitored log information should be published (e.g. ErrorCount) | `string` | n/a | yes |
| <a name="input_metric_transformation_namespace"></a> [metric\_transformation\_namespace](#input\_metric\_transformation\_namespace) | The destination namespace of the CloudWatch metric. | `string` | n/a | yes |
| <a name="input_metric_transformation_unit"></a> [metric\_transformation\_unit](#input\_metric\_transformation\_unit) | The unit to assign to the metric. If you omit this, the unit is set as None. | `string` | `null` | no |
| <a name="input_metric_transformation_value"></a> [metric\_transformation\_value](#input\_metric\_transformation\_value) | What to publish to the metric. For example, if you're counting the occurrences of a particular term like 'Error', the value will be '1' for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event. | `string` | `"1"` | no |
| <a name="input_name"></a> [name](#input\_name) | A name for the metric filter. | `string` | n/a | yes |
| <a name="input_pattern"></a> [pattern](#input\_pattern) | A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events. | `string` | n/a | yes |
Expand Down
1 change: 1 addition & 0 deletions modules/log-metric-filter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ resource "aws_cloudwatch_log_metric_filter" "this" {
namespace = var.metric_transformation_namespace
value = var.metric_transformation_value
default_value = var.metric_transformation_default_value
unit = var.metric_transformation_unit
}
}
6 changes: 6 additions & 0 deletions modules/log-metric-filter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ variable "metric_transformation_default_value" {
type = string
default = null
}

variable "metric_transformation_unit" {
description = "The unit to assign to the metric. If you omit this, the unit is set as None."
type = string
default = null
}
1 change: 1 addition & 0 deletions wrappers/log-metric-filter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ module "wrapper" {
metric_transformation_namespace = try(each.value.metric_transformation_namespace, var.defaults.metric_transformation_namespace)
metric_transformation_value = try(each.value.metric_transformation_value, var.defaults.metric_transformation_value, "1")
metric_transformation_default_value = try(each.value.metric_transformation_default_value, var.defaults.metric_transformation_default_value, null)
metric_transformation_unit = try(each.value.metric_transformation_unit, var.defaults.metric_transformation_unit, null)
}

0 comments on commit 5116f50

Please sign in to comment.