AWS Marketplace

Visualize your CloudWatch metrics with AWS resource tags in Coralogix from AWS Marketplace

Amazon CloudWatch is a staple when it comes to monitoring your Amazon Web Services (AWS) resources. CloudWatch metrics help you monitor virtually any of your AWS services, from Amazon Elastic Compute Cloud (Amazon EC2) instances through Amazon Relational Database Services (Amazon RDS) instances to your Amazon API Gateway. While CloudWatch provides a complete solution to monitoring AWS services and even offers a powerful query engine, some users will want to export their CloudWatch metrics into a third-party system in order to centralize their observability experience with their third-party services and correlate their AWS resource metrics with metrics coming from other sources. This is crucial for every organization’s success in their observability story since having all your observability signals in one place simplifies the usage of the data and lowers the time required to obtain the information your engineers’ need.

This is where Coralogix provides a solution. Coralogix is an AWS Partner Network (APN) Advanced technology partner with AWS DevOps Competency. Coralogix is the ultimate observability platform providing engineering teams with deep insights through real-time analysis, monitoring, visualization, and alerting with no reliance on storage or indexing. Coralogix is an AWS Marketplace seller where customers can purchase the Coralogix platform as a software-as-a-service (SaaS) solution.

This post will show you how to take your CloudWatch metrics to the next level by using your AWS resource tags in your monitoring setup. Thanks to the support for native enhancement of the metrics in the CloudWatch streams pipeline through a transformation Lambda, users will be able to label their resource tags directly on their metrics. This feature unlocks the possibility of visualizing users’ metrics based on their business logic and creating customized dashboards in their Coralogix account. This will add more flexibility for the DevOps team to design more sophisticated dashboards and draw better insights from their AWS services and infrastructures.

Solution Overview

Figure 1: Overall architecture diagram of how users can visualize AWS metrics in Coralogix

Figure 1: Overall architecture diagram of how users can visualize AWS metrics in Coralogix

CloudWatch provides a straightforward way to export your metrics to external systems using metric streams. The whole pipeline consists of CloudWatch sending metric streams continually to an Amazon Data Firehose delivery stream, which delivers the metrics to the Coralogix backend. The metrics can be optionally transformed in the pipeline with an AWS Lambda function.

CloudWatch metric streams Lambda transformation makes adding your resource tags to metrics easy and seamless. You can install the Lambda as part of your CloudWatch metric streams pipeline, and it will automatically enrich your CloudWatch metrics with resource tags before they are exported to Coralogix. Because the metrics are enriched on the fly, the resource tags will be available in your metrics as labels and can therefore be used directly in your queries without the need to do joins.

The transformation Lambda:

  • Accepts Amazon Data Firehose events with metric data in OpenTemetry protocol (OTLP) format 7, size-delimited format (as exported by the CloudWatch streams)
  • Obtains AWS resource information through the AWS tagging API and related APIs (such as Amazon API Gateway or Amazon EC2)
  • Associates CloudWatch metrics with particular resources and enriches the metric labels with resource tags
  • Allows for optionally failing the export process if metrics enrichment fails (or continue exporting without enriching)
  • Supports caching between Lambda invocations to prevent rate limiting and speed up Lambda runs, which is by default a 1-hour cache time to live (TTL)
  • Returns Amazon Data Firehose response with transformed record in OTLP v0.7, size-delimited format, for further processing and exporting to Coralogix (or other compatible backend)

Prerequisites

Before getting started, the following prerequisites are required:

  1. An AWS account with appropriate IAM roles and permissions
  2. A Coralogix production account or a free trial account. Coralogix’s account can be obtained in the Coralogix AWS Marketplace listing or through Coralogix’s own free trial sign-up (you only need an e-mail).

Visualizing your CloudWatch metrics with Coralogix custom dashboards

To start receiving and visualizing your CloudWatch metrics, following the steps below:

  • Go to your AWS account and create a new CloudWatch Metrics Stream with Amazon Data Firehose, if you don’t have one yet.
  • In order to enable the metrics enhancement, you’ll need to set up the transformation Lambda. Download the Lambda function.
  • Create a new Lambda function in your AWS account. Choose Author from scratch, provide a name to the function, and choose runtime Amazon Linux 2023 (OS-only runtime for Go, Rust, C++, custom). Choose Create function, and after the function is created, upload the downloaded .zip file as the source for the Lambda.
  • Return to the Amazon Data Firehose you created previously, and in the Configuration screen, choose Edit in the Transform records Choose the uploaded Lambda from the list of available functions. Choose Save changes.
  • Verify that your Lambda function has all the necessary permissions as described in the documentation in GitHub.

If you prefer, the whole setup can be easily automated with our Terraform module. It is also important to watch for any delays in the delivery of the metrics. In the Monitoring section of your Amazon Data Firehose delivery stream, you can look at the Delivery to HTTP endpoint data freshness graph. The graph shows the staleness of data being delivered through the delivery stream in seconds.

The greater the staleness of data, the bigger the delay in delivery of the data to your Coralogix account will be. Increased staleness can be caused by slow Lambda runs, especially if you’re exporting a large number of metric points from your CloudWatch service. In order to prevent any disruption to your data delivery and depending on the size of your setup, we also recommend adjusting your Lambda buffer hint and Amazon Data Firehose buffer size configuration. For the most optimal experience, we recommend setting the Lambda buffer hint to 0.2 MB and the Amazon Data Firehose buffer size to 1 MB. Beware that this might cause more frequent Lambda runs, which might result in higher costs.

Go back to your Coralogix account. You should now start seeing incoming CloudWatch metrics enriched with your AWS tags:

  • Choose Custom Dashboards and add a new dashboard by clicking on Create New Dashboard
Figure 2: Creating custom dashboard in your Coralogix account

Figure 2: Creating custom dashboard in your Coralogix account

  • Add items you’d like to see in your dashboard (such as line charts, data tables, or gauges) and provide an appropriate PromQL query. In this example, we are creating a dashboard to visualize the CPU utilization of your EC2 instances as a line chart.
Figure 3: Adding items to your new dashboard

Figure 3: Adding items to your new dashboard

  • Choose the manage filters icon to open the menu and choose New Filter. From Source, choose Metrics. Now you can choose a Label Name that corresponds to your desired AWS tag. In our example, we want to be able to filter by our environment label (production or development).
Figure 4: Choose the label name based on the AWS tag

Figure 4: Choose the label name based on the AWS tag

  • Choose Save and your custom filter will now appear. You can choose to visualize your dashboard based on filter values.
Figure 5: Final dashboard in Coralogix platform

Figure 5: Final dashboard in Coralogix platform

Cleanup

Follow the steps below to remove services and avoid associated runtime cost:

  1. Delete the Amazon CloudWatch metrics stream together with the Data Firehose delivery stream and Lambda function created through the AWS console
  2. In Coralogix account, delete the metrics stream and dashboard you created

Conclusion

In this post, we have shown how easy it is to enrich your CloudWatch metrics with a transformation Lambda. You can now use your AWS tags directly as labels on your metrics data and design more sophisticated metric dashboards according to your own business logic. Furthermore, you can now easily visualize your CloudWatch metrics as custom dashboards in your Coralogix account and filter based on your custom tags and business needs, such as by environment or the team owning the resource.

Visit CloudWatch Metric Streams with Amazon Data Firehose for detailed steps on how to set up the integration. Also, AWS customers can go to this AWS Marketplace listing to purchase the Coralogix SaaS with just a few clicks.

About Authors

Shun Mao

Shun Mao is a senior partner solutions architect in the artificial intelligence and machine learning (AI/ML) independent software vendor (ISV) partner team at Amazon Web Services. He has years of experience in data science, analytics, AI, and cloud across different industries, including oil and gas and pharmaceuticals. At AWS, he is helping strategic AI/ML partners to build novel products and solutions to bring business value to customers. Outside of work, he enjoys fishing, traveling, and playing ping-pong.

Matej Gera

Matej Gera is a senior software engineer at Coralogix. He is a part of the ecosystem team, which focuses working on observability agents, mainly in the context of OpenTelemetry. He has 5+ years of experience working with cloud-native technologies and observability software.