Monitoring Your Timescale Services With Amazon CloudWatch

Monitoring Your Timescale Services With Amazon CloudWatch

Many of our customers are using Timescale for mission-critical applications. These services require close monitoring to ensure end-users don’t suffer service interruptions due to the lack of resources. Our previous post explained how you can monitor your Timescale service metrics with Datadog. Today, we’ll do the same with Amazon CloudWatch, which is especially interesting if you are already using this service to monitor other elements of your AWS infrastructure.

In this blog post, we walk you through integrating Timescale and CloudWatch to monitor your memory, CPU, and storage metrics. Timescale is the safest and most convenient way to run TimescaleDB databases in production, as it automates many of the most painful database management tasks—like backups, high availability, failover, scaling, upgrades, and much more. If you are not using Timescale yet, you can create an account here and use it entirely for free for 30 days.

We also cover the steps needed to integrate Timescale and CloudWatch in the video below:

Editor's Note: We’re also working on a Prometheus integration, which will be coming soon. Stay tuned!

Prerequisites

To follow this tutorial, you must have an AWS account with the necessary permissions to create new users and policies.

You also need to have a Timescale service running. Exporting usage metrics data is a free feature on Timescale, and it is also available for trial users—you can start a free trial here.

Timescale and Amazon CloudWatch: Under the Hood

Before jumping into the tutorial, let’s take a quick look at how this integration works in Timescale. This will help you make sense of the steps you’ll perform later:

  • Timescale has an internal metrics collector service that silently watches all your Timescale services created in a particular region (e.g., us-east-1).
  • If you want to expose the metrics for a specific service and send them to an observability tool like Amazon CloudWatch, you will first create an “exporter” in Timescale.
  • Once you have created an exporter (linked to a specific region and a specific observability tool), you will attach the exporter to the service you want to monitor. This under-the-hood exporter is OpenTelemetry—it will give your metrics the correct format.
  • Once your service is attached to the exporter, your service metrics will be sent automatically to CloudWatch.
Architecture diagram showcasing the basic integration elements between Timescale Cloud and Amazon CloudWatch
Architecture diagram showcasing the basic integration elements between Timescale and Amazon CloudWatch

Configuring Amazon CloudWatch

The first step to set up this integration is getting the necessary credentials for CloudWatch, namely an access key and a secret key:

  • Head to the “Identity and Access Management (IAM)” console in AWS.
  • Navigate to Users and click on “Add user.” On the first screen, give your user a descriptive name, and select “Access key - Programmatic access.”
The user interface with the steps to Add User
  • On the next screen, select “Attach existing policies directly.” Search for “CloudWatchFullAccess,” select the policy, and click Next.
The steps for attaching existing policies directly
  • On the following screen, you can add tags to help identify this user, but this is optional.
  • Once you create your user, write down the access and security keys.

Exporting Metrics From Timescale

Now, let’s jump to the Timescale user interface.

As we saw earlier, you first need to create an exporter to configure your Datadog destination in Timescale. Exporters in Timescale are associated with a particular third-party tool (e.g., CloudWatch) and have an associated AWS region. If you want to monitor different services across multiple regions (for example, one service in eu-west-1 and another in us-east-1), you’ll need to create two exporters, one per region. If the regions match, you can attach multiple services to only one exporter.  

To create a CloudWatch exporter in Timescale, follow these steps:

  • Navigate to the Integrations page in the left menu.
The Integrations page in the left menu
  • On the Integrations page, click on “Add exporter.”
  • You’ll be taken to the configuration page for your exporter. Here, select the tool you want to integrate your service with—in this case, CloudWatch. Also, choose the Timescale region for this exporter (remember that this needs to be the same region as the service you want to export metrics from).
The Create an exporter menu
  • Next, configure your CloudWatch exporter. You’ll need to define a log group name, log stream name, and namespace (these are all CloudWatch mandatory parameters). To get started, you can keep the defaults. For the CloudWatch credentials, use the ones you retrieved earlier. And for the region, select the same as your Timescale service.
The menu for configuring the Cloud exporter
  • You can also define an IAM role (an identity you can create in your account with specific permissions) for uploading metrics. This step is optional, but having a dedicated role with only CloudWatch permissions is a recommended security practice.
  • Once you’re done, click on “create exporter.”

Your exporter is now live. The next step is connecting your service to the exporter, so telemetry data starts flowing into CloudWatch.

To do that, navigate to the Operations page of your service, and click on “Integrations.” Select the exporter you previously created in the drop-down menu, and click on “Attach exporter.”

Attaching the exporter in the user interface

Your service metrics are now accessible via Amazon CloudWatch! 🎉

To check that everything works, navigate to the Metrics page in CloudWatch and see if you can access your Timescale metrics. You should see a “Timescale” custom namespace in the Query menu. The metrics coming from your Timescale service start with timescale.cloud.*.

The CloudWatch metrics user interface

P.S. In CloudWatch, your Timescale services are identified by a service_id. You can see the service_id of a specific service by looking at the first part of the hostname. For example, your hostname may be mnyr5wrz9u.ye21f71f94.dev.metronome-cloud.com—your service_id is mnyr5wrz9u.

Wrapping Up

You can now integrate Timescale with Amazon CloudWatch to monitor your service metrics.

If you have a time-series application, Timescale is the most convenient way to run your database fleet. You’ll get the top performance of TimescaleDB for your time-series data—with automatic time partitioning, native compression, continuous aggregation, and SQL hyperfunctions for time-series analysis—plus all the advantages of PostgreSQL for your relational data. All this without the stress of manually managing backups, failover, or replication. You can try Timescale Cloud for free anytime; no credit card required.

But there’s more: you will soon be able to use Amazon CloudWatch to monitor performance metrics in Timescale. Stay tuned and happy monitoring!

Ingest and query in milliseconds, even at terabyte scale.
This post was written by
5 min read
Cloud
Contributors

Related posts