Skip to content

Commit

Permalink
feat(aws): add support for metric filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sjauld committed Oct 29, 2024
1 parent bee416b commit 04e81ec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
18 changes: 18 additions & 0 deletions examples/modules/cloud-integrations/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ resource "aws_cloudwatch_metric_stream" "newrelic_metric_stream" {
role_arn = aws_iam_role.metric_stream_to_firehose.arn
firehose_arn = aws_kinesis_firehose_delivery_stream.newrelic_firehose_stream.arn
output_format = "opentelemetry0.7"

dynamic "exclude_filter" {
for_each = var.exclude_metric_filters

content {
namespace = exclude_filter.key
metric_names = exclude_filter.value
}
}

dynamic "include_filter" {
for_each = var.include_metric_filters

content {
namespace = include_filter.key
metric_names = include_filter.value
}
}
}

resource "newrelic_cloud_aws_link_account" "newrelic_cloud_integration_pull" {
Expand Down
12 changes: 12 additions & 0 deletions examples/modules/cloud-integrations/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ variable "name" {
type = string
default = "production"
}

variable "exclude_metric_filters" {
description = "Map of exclusive metric filters. Use the namespace as the key and the list of metric names as the value."
type = map(list(string))
default = {}
}

variable "include_metric_filters" {
description = "Map of inclusive metric filters. Use the namespace as the key and the list of metric names as the value."
type = map(list(string))
default = {}
}
14 changes: 10 additions & 4 deletions website/docs/guides/cloud_integrations_guide.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ module "newrelic-aws-cloud-integrations" {
newrelic_account_id = 1234567
newrelic_account_region = "US"
name = "production"
include_metric_filters = {
"AWS/EC2" = [], # include ALL metrics from the EC2 namespace
"AWS/S3" = ["NumberOfObjects"]. # include just a specific metric from the S3 namespace
}
}
```

Expand All @@ -68,10 +73,11 @@ module "newrelic-aws-cloud-integrations" {

Variables:

* newrelic_account_id: The New Relic account you want to link to AWS. This account will receive all the data observability from your AWS environment.
* newrelic_account_region: The region of your New Relic account, this can be `US` for United States or `EU` for Europe. (Default `US`)
* name: A unique name used throughout the module to name the resources.

* `newrelic_account_id`: The New Relic account you want to link to AWS. This account will receive all the data observability from your AWS environment.
* `newrelic_account_region` (Optional): The region of your New Relic account, this can be `US` for United States or `EU` for Europe. (Default `US`)
* `name` (Optional): A unique name used throughout the module to name the resources. (Default `production`)
* `exclude_metric_filters` (Optional): a map of namespaces and metric names to exclude from the Cloudwatch metric stream. `Conflicts with include_metric_filters`.
* `include_metric_filters` (Optional): a map of namespaces and metric names to include in the Cloudwatch metric stream. `Conflicts with exclude_metric_filters`.

### Azure

Expand Down

0 comments on commit 04e81ec

Please sign in to comment.