Skip to content

Cloudwatch

Amazon CloudWatch is a monitoring and observability service provided by AWS. It collects metrics, logs, and event data from various AWS resources and applications, allowing you to gain actionable insights into system performance and operational health.

Configure Martini Runtime to send Metrics to Cloudwatch

This guide helps you configure Martini Runtime to send metrics to AWS CloudWatch, facilitating the monitoring of your application's performance. If you encounter any issues, refer to the AWS CloudWatch documentation or seek support from the AWS community.

Dependencies

To get CloudWatch working with Martini, you’ll need to download and add the following jar files to the lib/ext folder of your Martini Runtime.

Please ensure you use the specified versions:

  1. Micrometer-registry-cloudwatch:1.9.0

    This file contains the necessary tools to send your metrics to CloudWatch at the interval specified in your application.properties.

  2. AWS Java SDK for CloudWatch:1.12.151

    This file enables integration between Martini and CloudWatch.

Martini Runtime Setup

  • Import the downloaded JAR files on Martini.

  • Configure the application.properties with the following properties:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    # Expose metrics endpoint
    management.endpoints.web.exposure.include=metrics
    
    # Set the AWS region manually (e.g., us-east-1)
    cloud.aws.region.static=us-east-1
    
    # Disable automatic region detection (important for local development to avoid unintended region usage)
    cloud.aws.region.auto=false
    
    # Disable automatic AWS CloudFormation stack configuration (useful when running the app locally)
    cloud.aws.stack.auto=false
    
    # Specify the file path to the AWS credentials file 
    cloud.aws.credentials.profile-path=/path/to/your/aws/credentials/file
    cloud.aws.credentials.profile-name=profile_name_here
    
    # If CloudWatch integration should be enabled.
    management.metrics.export.cloudwatch.enabled=true
    
    # The specific region for CloudWatch integration.
    management.metrics.export.cloudwatch.region=us-east-1
    
    # The interval at which metrics are sent to CloudWatch. Can be set
    #in minutes (m) or hours (h)
    management.metrics.export.cloudwatch.step=10s
    
    # The namespace which will be used when sending metrics to CloudWatch. 
    #This property is needed and must not be null.
    management.metrics.export.cloudwatch.namespace=YourNamespaceHere
    
    # The specific endpoint for CloudWatch integration. If testing with AWS #Emulator LocalStack, you may set localstack endpoint here
    management.metrics.export.cloudwatch.endpoint=monitoring.us-east-1.amazonaws.com
    management.metrics.export.cloudwatch.batchSize=20
    
  • Configure logging to check and make sure metrics data are being pushed:

    1
    2
    logging.level.io.micrometer=DEBUG
    logging.level.io.micrometer.cloudwatch=DEBUG
    

Query Metrics

  • In the AWS Management Console, click on CloudWatch.
  • Select "All Metrics" in the left navigation panel.
  • The Martini Runtime metrics will be stored under the namespace you indicated in the application.properties file, under “Custom namespaces”.
  • Type in the metric you want to query then press Enter.
  • Select the metric then click "Graph this metric only".

You can now view the Martini Runtime metric values graphed.