Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.95 KB

README.md

File metadata and controls

63 lines (45 loc) · 1.95 KB

AWS App Runner Metrics

This AWS CDK construct export the default metrics created by the App Runner Service, you can use them to create dashboards or alarms.

Requirements To use this construct, you'll need the following:

  • An AWS account with the necessary permissions to create AWS AppRunner and AWS CloudFormation resources.
  • AWS CDK v2 installed and configured on your development machine.
  • Node.js and TypeScript installed on your development machine.

Getting Started

To get started with this library, follow these steps:

  1. Install the library in your AWS CDK project by running the following command:
npm install cdk-apprunner-metrics

or, with yarn:

yarn add cdk-apprunner-metrics
  1. Import it in your CDK stack:
import { AppRunnerMetrics } from "cdk-apprunner-metrics";
  1. Instantiate the CfnService construct in your AWS CDK stack and provide the required parameters:
const service = new apprunner.CfnService(this, "AppRunnerService", {
  serviceName: id,
  /** Other config... **/
});
  1. Get the metric you desire:
const http2xxCountMetric = AppRunnerMetrics.http2xxResponseCount(service);
const http4xxCountMetric = AppRunnerMetrics.http4xxResponseCount(service);
const http5xxCountMetric = AppRunnerMetrics.http5xxResponseCount(service);
const requestLatencyMetric = AppRunnerMetrics.requestLatency(service);
const activeInstancesMetric = AppRunnerMetrics.activeInstances(service);
const cpuUtilizationMetric = AppRunnerMetrics.cpuUtilization(service);
const memoryUtilizationMetric = AppRunnerMetrics.memoryUtilization(service);
const concurrencyMetric = AppRunnerMetrics.concurrency(service);
  1. You can use your metrics on whatever place you like.

  2. You can also reference log groups for set up alarms if you like:

const svcLogGroup = AppRunnerMetrics.serviceLogGroup(this, `ServiceLogGroup`, service);
const appLogGroup = AppRunnerMetrics.applicationLogGroup(this, `AppLogGroup`, service);