Skip to content

Commit 5116f50

Browse files
shashimalDuleendra Shashimalantonbabenko
authored
feat: Add option to specify metric transformation unit (#49)
Co-authored-by: Duleendra Shashimal <duleendra@bambu.co> Co-authored-by: Anton Babenko <anton@antonbabenko.com>
1 parent ef8a0aa commit 5116f50

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

modules/log-metric-filter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ No modules.
3333
| <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 |
3434
| <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 |
3535
| <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 |
36+
| <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 |
3637
| <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 |
3738
| <a name="input_name"></a> [name](#input\_name) | A name for the metric filter. | `string` | n/a | yes |
3839
| <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 |

modules/log-metric-filter/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ resource "aws_cloudwatch_log_metric_filter" "this" {
1010
namespace = var.metric_transformation_namespace
1111
value = var.metric_transformation_value
1212
default_value = var.metric_transformation_default_value
13+
unit = var.metric_transformation_unit
1314
}
1415
}

modules/log-metric-filter/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ variable "metric_transformation_default_value" {
4141
type = string
4242
default = null
4343
}
44+
45+
variable "metric_transformation_unit" {
46+
description = "The unit to assign to the metric. If you omit this, the unit is set as None."
47+
type = string
48+
default = null
49+
}

wrappers/log-metric-filter/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ module "wrapper" {
1111
metric_transformation_namespace = try(each.value.metric_transformation_namespace, var.defaults.metric_transformation_namespace)
1212
metric_transformation_value = try(each.value.metric_transformation_value, var.defaults.metric_transformation_value, "1")
1313
metric_transformation_default_value = try(each.value.metric_transformation_default_value, var.defaults.metric_transformation_default_value, null)
14+
metric_transformation_unit = try(each.value.metric_transformation_unit, var.defaults.metric_transformation_unit, null)
1415
}

0 commit comments

Comments
 (0)