Monitoring AWS App Monetization with Amazon CloudWatch
You can track the number of active subscriptions to each of your apps with a metric in Amazon CloudWatch. AWS App Monetization sends the metric to your AWS account every 5 minutes. You don't need to turn it on.
The metric uses the OpenTelemetry format. You query it with the Prometheus Query
Language (PromQL), for example in CloudWatch Query Studio, on a CloudWatch dashboard, or in a CloudWatch
alarm. For more information about querying metrics with PromQL, see Query metrics with
PromQL in the Amazon CloudWatch User Guide. Querying metrics can incur
CloudWatch charges. For more information about CloudWatch pricing, see Amazon CloudWatch pricing
AWS App Monetization metric
The following table describes the metric that AWS App Monetization sends.
| Metric | Type | Unit | Description |
|---|---|---|---|
|
Gauge |
|
Number of active subscriptions to this app. Each data point is the count at the time that AWS App Monetization read it. |
A subscription counts as active when your customer has a current plan and the subscription isn't past due or suspended. A subscription that your customer cancels stops counting as soon as the cancellation is requested, even when the plan stays in effect until the end of the billing period.
AWS App Monetization sends one data point for each app. The count includes Live subscriptions
only. Test subscriptions in Sandbox aren't counted. An app with no active subscriptions
reports 0.
Metric attributes
Each data point carries the following resource attributes. In PromQL, a resource
attribute is a label that starts with @resource..
| PromQL label | Description | Example |
|---|---|---|
|
The ID of the app. |
|
|
The ARN of the app. |
|
|
The AWS account that owns the app. |
|
|
The AWS Region of the app. |
|
|
The cloud provider. |
|
The instrumentation scope label @instrumentation.@name is
cloudwatch.aws/appmonetization for every data point.
Example queries
The following query returns the number of active subscriptions to one app. Replace
01a1EXAMPLEAPPID7f3e2b1c with the ID of your app.
{"aws.appmonetization.subscription.active", "@resource.aws.appmonetization.app.id"="01a1EXAMPLEAPPID7f3e2b1c"}
The query has the following parts:
-
aws.appmonetization.subscription.active– The name of the metric. -
@resource.aws.appmonetization.app.id– The label that selects one app by its ID.
The following query returns the total number of active subscriptions across all of your apps in the Region.
sum({"aws.appmonetization.subscription.active"})
Creating an alarm on the metric
You can create a CloudWatch alarm that notifies you when the number of active subscriptions crosses a threshold. To create the alarm, choose PromQL as the metric type in the CloudWatch console and enter a query that returns one time series. For instructions on creating an alarm with a PromQL query, see Create an alarm using a PromQL query in the Amazon CloudWatch User Guide.
For example, the following query goes into alarm when an app has no active subscriptions.
In the following query, replace 01a1EXAMPLEAPPID7f3e2b1c with the ID of
your app.
{"aws.appmonetization.subscription.active", "@resource.aws.appmonetization.app.id"="01a1EXAMPLEAPPID7f3e2b1c"} < 1