Skip to content

Firehose Metrics Module

Firehose Metrics module is designed to support AWS Firehose Metrics integration with Coralogix. Leveraging AWS CloudWatch Metrics Stream.

Metrics - Usage

Delivering all CloudWatch metrics

Provision a firehose delivery stream with CloudWatch metric stream to stream metrics to Coralogix.

module "cloudwatch_firehose_metrics_coralogix" {
  source           = "coralogix/aws/coralogix//modules/firehose-metrics"
  firehose_stream  = var.coralogix_firehose_stream_name
  api_key          = var.api_key
  coralogix_region = var.coralogix_region
}

By default, the metric stream includes all namespaces [AWS/EC2, AWS/EBS, etc..] and metric names.

Delivering selected CloudWatch metrics by namespaces

Provision a firehose delivery stream with CloudWatch metric stream. The metric stream includes only selected namespaces and sends the metrics to Coralogix: When including specific namespaces, the variable 'include_metric_stream_namespaces' needs to include a list of the desired namespaces, which are case-sensitive. please see the AWS namespaces list.

module "cloudwatch_firehose_metrics_coralogix" {
  source                           = "coralogix/aws/coralogix//modules/firehose-metrics"
  firehose_stream                  = var.coralogix_firehose_stream_name
  api_key                          = var.api_key
  include_metric_stream_namespaces = var.include_metric_stream_namespaces
  coralogix_region                 = var.coralogix_region
}

Filtering selected metric names from namespaces

Provision a firehose delivery stream with CloudWatch metric stream. For more granular inclusive filters of metric names belonging to an included namespace:

The variable include_metric_stream_filter can be used to send only conditional metric names belonging to a selected metric namespace. For any selected namespace where the metric names list is empty or not specified, all metrics in that namespace is included.

Note: include_metric_stream_namespaces and include_metric_stream_filter are independent but related the same metric stream include filter and may conflict. If error or metrics do not show, check console CloudWatch -> Metrics -> Streams -> Selected Metrics table on result.

Metric namespaces are also case-sensitive, please see the AWS namespaces list. For case-sensitive metric names belonging to a namespace, please see the AWS View available metrics guide

module "cloudwatch_firehose_metrics_coralogix" {
  source                           = "coralogix/aws/coralogix//modules/firehose-metrics"
  firehose_stream                  = var.coralogix_firehose_stream_name
  api_key                          = var.api_key

  # If metric names is empty or not specified, the whole metric namespace is included
  include_metric_stream_filter     = [
    {
      namespace    = "AWS/EC2"
      metric_names = ["CPUUtilization", "NetworkOut"]
    },
    {
      namespace    = "AWS/S3"
      metric_names = ["BucketSizeBytes"]
    },
  ]
  coralogix_region                 = var.coralogix_region
}

Additional Statistics

Also, additional_metric_statistics provide a means to configure additional statistics to a given metric. This is done by specifying the metric_name and namespace and corresponding list of additional statistics. Read metric streams for more infomation. Set additional_metric_statistics_enable to true to enable this featurem,

Depending on the output_format variable configured (default opentelemetry0.7). The json format would support streaming of statistics provided by CloudWatch and the opentelemetry0.7 (default) supports streaming percentile statistics (p99.).

If additional_metric_statistics is not configured but is enabled true, the module's default configuration of recommended metric and statistics is used which is configured to the p50, p75, p95 and p99 percentiles.

In the below example, additional_metric_statistics is enabled and the default configured metrics, namespaces and additional statistics percentiles are used. Note: as output_format of opentelemetry0.7 is configured, only percentile values are supported.

output_format = "opentelemetry0.7"

additional_metric_statistics_enable = true
additional_metric_statistics = [
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "VolumeTotalReadTime",
    namespace             = "AWS/EBS"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "VolumeTotalWriteTime",
    namespace             = "AWS/EBS"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "Latency",
    namespace             = "AWS/ELB"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "Duration",
    namespace             = "AWS/ELB"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "PostRuntimeExtensionsDuration",
    namespace             = "AWS/Lambda"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "FirstByteLatency",
    namespace             = "AWS/S3"
  },
  {
    additional_statistics = ["p50", "p75", "p95", "p99"],
    metric_name           = "TotalRequestLatency",
    namespace             = "AWS/S3"
  }
]

Cross-account Tag Enrichment (OAM)

When using OAM linked accounts, enable Lambda cross-account tag enrichment to fetch tags from source accounts:

## Enable cross-account tag enrichment
cross_account_enabled = true

## Map each source account ID to the role to assume in that account
cross_account_roles = {
  "123456789012" = "arn:aws:iam::123456789012:role/CoralogixMetricsReader"
}

Required permissions: - Monitoring account Lambda role must allow sts:AssumeRole on each role in cross_account_roles. - Each linked account role trust policy must allow the monitoring account Lambda processor role to assume it. - Linked account role policy should include at least tag:GetResources and service-specific read actions used for resource discovery.

Removal of CloudWatch Metric Streams Lambda transformation

By default, a Coralogix Lambda Transformation Function has been added to the Kinesis Firehose Data Transformation as a processing_configuration. This is done, to enrich the metrics from CloudWatch Metric Streams with AWS resource tags. The optional lambda function is deployed as part of the module, and can be removed by setting the variable lambda_processor_enable to false.

module "cloudwatch_firehose_metrics_coralogix" {
  source                           = "coralogix/aws/coralogix//modules/firehose-metrics"
  lambda_processor_enable          = false
  firehose_stream                  = var.coralogix_firehose_stream_name
  api_key                          = var.api_key
  coralogix_region                 = var.coralogix_region
}

Read more about the following:

Examples

Examples can be found under the firehose-metrics examples directory

Override Coralogix applicationName and subsystemName

The application name and subsystem name by default is the firehose delivery stream arn and name, but it can be overriden by setting an environment variable called application_name and subsystem_name.

Coralogix account region

The coralogix region variable accepts one of the following regions: * EU1 * EU2 * AP1 * AP2 * AP3 * US1 * US2

Coralogix Regions & Description.

RegionDomainEndpoint
EU1eu1.coralogix.comhttps://ingress.coralogix.com/aws/firehose
EU2eu2.coralogix.comhttps://ingress.eu2.coralogix.com/aws/firehose
AP1ap1.coralogix.comhttps://ingress.app.ap1.coralogix.com/aws/firehose
AP2ap2.coralogix.comhttps://ingress.ap2.coralogix.com/aws/firehose
AP3ap3.coralogix.comhttps://ingress.ap3.coralogix.com/aws/firehose
US1us1.coralogix.comhttps://ingress.us1.coralogix.com/aws/firehose
US2us2.coralogix.comhttps://ingress.us2.coralogix.com/aws/firehose

Custom endpoints

It is possible to pass a custom firehose ingress endpoint with by using the coralogix_firehose_custom_endpoint variable.

Metrics Output Format

Coralogix suppots both JSON format and OpenTelemtry format. The default format configured here is OpenTelemtry. if using Json in the firehose output format, which is configured via the integration_type_metrics variable, then the CloudWatch metric stream must be configured with the same format, configured via the output_format variable.

Requirements

NameVersion
aws~> 4.17.1
terraform>= 1.6.0

Providers

NameVersion
aws~> 4.17.1

Inputs

NameDescriptionTypeDefaultRequired
coralogix_regionCoralogix account region: EU1, EU2, AP1, AP2, AP3, US1, US2 [exact]anyn/ayes
api_keyCoralogix account logs api keystringn/ayes
firehose_streamAWS Kinesis firehose delivery stream namestringn/ayes
application_nameThe name of your application in Coralogixstringn/ayes
subsystem_nameThe subsystem name of your application in Coralogixstringn/ayes
cloudwatch_retention_daysDays of retention in Cloudwatch retention daysnumbern/ano
custom_domainCustom domain for Coralogix firehose integration endpoint (private.coralogix.net:8443)stringnullno
integration_type_metricsThe integration type of the firehose delivery stream: CloudWatch_Metrics_OpenTelemetry070 or CloudWatch_Metrics_OpenTelemetry070_WithAggregations. For _WithAggregations choice, additional aggregations here are _min, _max, _avg recorded as gauges. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-formats-opentelemetry-translation.htmlstring"CloudWatch_Metrics_OpenTelemetry070_WithAggregations"no
output_formatThe output format of the cloudwatch metric stream: 'json' or 'opentelemetry0.7'string"opentelemetry0.7"no
enable_cloudwatch_metricstreamShould be true if you want to create a new CloudWatch metric stream and attach it to Firehosebooltrueno
cloudwatch_metric_stream_custom_nameSet the name of the CloudWatch Metric Stream resource, otherwise variable firehose_stream will be usedstringnullno
include_metric_stream_namespacesList of specific namespaces to include in the CloudWatch metric stream, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.htmllist(string)[]no
include_metric_stream_filterGuide to view specific metric names of namespaces, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/viewing_metrics_with_cloudwatch.htmllist(object({namespace=string, metric_names=list(string)})[]no
include_linked_accounts_metricGuide to view specific metric names of namespaces, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/viewing_metrics_with_cloudwatch.htmllist(object({namespace=string, metric_names=list(string)})[]no
additional_metric_statistics_enableTo enable the inclusion of additional statistics to the streaming metricsbooltrueno
additional_metric_statisticsFor each entry, specify one or more metrics (metric_name and namespace) and the list of additional statistics to stream for those metrics. Each configuration of metric name and namespace can have a list of additional_statistics included into the AWS CloudWatch Metric Stream.list(object({additional_statistics=list(string), metric_name=string, namespace=string}))See variables.tfno
s3_backup_custom_nameSet the name of the S3 backup bucket, otherwise variable '{firehose_stream}-backup-metrics' will be used.stringn/ano
existing_s3_backupUse an existing S3 bucket to use as a backup bucket.stringn/ano
govcloud_deploymentEnable if you deploy the integration in govcloudboolfalseno
custom_s3_bucketThe name of the s3 bucket that exists in your account to save the lambda zip code instringn/ano
lambda_processor_enableEnable the lambda processor function. Set to false to remove the lambda and all associated resources.booltrueno
lambda_processor_custom_nameSet the name of the lambda processor function, otherwise variable '{firehose_stream}-metrics-transform' will be usedstringnullno
lambda_processor_iam_custom_nameSet the name of the lambda processor IAM role, otherwise variable '{firehose_stream}-lambda-processor-iam' will be used.stringn/ano
existing_lambda_processor_iamUse an existing lambda processor IAM role.stringn/ano
firehose_iam_custom_nameSet the name of the IAM role & policy, otherwise variable '{firehose_stream}-firehose-metrics-iam' will be used.stringn/ano
existing_firehose_iamUse an existing IAM role to use as a firehose role.stringn/ano
metric_streams_iam_custom_nameSet the name of the cloudwatch metric streams IAM role & policy, otherwise variable '{firehose_stream}-cw-iam.stringn/ano
existing_metric_streams_iamUse an existing IAM role to use as a metric streams role.stringn/ano
user_supplied_tagsTags supplied by the user to populate to all generated resourcesmap(string)n/ano
override_default_tagsOverride and remove the default tags by setting to trueboolfalseno

Coralgoix regions

Coralogix regionAWS RegionCoralogix Domain
Europeeu-west-1eu1.coralogix.com
Europe2eu-north-1eu2.coralogix.com
Indiaap-south-1ap1.coralogix.com
Singaporeap-southeast-1ap2.coralogix.com
AP3ap-southeast-3ap3.coralogix.com
USus-east-2us1.coralogix.com
US2us-west-2us2.coralogix.com

Note

When trying to deploy the lambda in govcloud, you will need to set the variable govcloud_deployment to true and set the variable custom_s3_bucket to a bucket that exists in your account, the module will upload the function source code into this bucket

Outputs

NameDescription
firehose_stream_arnARN of the Firehose Delivery Stream
firehose_stream_nameName of the Firehose Delivery Stream
firehose_iam_role_arnARN of the Firehose IAM role
s3_backup_bucket_arnARN of the Firehose S3 Backup Bucket
lambda_processor_arnARN of the Lambda Processor
lambda_processor_iam_arnARN of the Lambda Processor IAM role
metric_stream_arnARN of the CloudWatch Metric Stream
metric_stream_iam_role_arnARN of the CloudWatch Metric Stream IAM role