Logging metrics for AWS AppConfig data plane calls
If you configured AWS CloudTrail to log AWS AppConfig data events, you can enable Amazon CloudWatch Logs to log metrics for calls to the AWS AppConfig data plane. You can then search and filter log data in CloudWatch Logs by creating one or more metric filters. Metric filters define the terms and patterns to look for in log data as it is sent to CloudWatch Logs. CloudWatch Logs uses metric filters to turn log data into numerical CloudWatch metrics. You can graph metrics or configure them with an alarm.
Before you begin
Enable logging of AWS AppConfig data events in AWS CloudTrail. The following procedure describes how to enable metric logging for an existing AWS AppConfig trail in CloudTrail. For information about how to enable CloudTrail logging for AWS AppConfig data plan calls, see AWS AppConfig data events in CloudTrail.
Use the following procedure to enable CloudWatch Logs to log metrics for calls to the AWS AppConfig data plane.
To enable CloudWatch Logs to log metrics for calls to the AWS AppConfig data plane
Open the CloudTrail console at https://console.aws.amazon.com/cloudtrail/
. -
On the dashboard, choose your AWS AppConfig trail.
-
In the CloudWatch Logs section, choose Edit.
-
Choose Enabled.
-
For Log group name, either leave the default name or enter a name. Make a note of the name. You will choose the log group in the CloudWatch Logs console later.
-
For Role name, enter a name.
-
Choose Save changes.
Use the following procedure to create a metric and a metric filter for AWS AppConfig in CloudWatch Logs.
The procedure describes how to create a metric filter for calls by operation
and
(optionally) calls by operation
and Amazon Resource Name
(ARN)
.
To create a metric and a metric filter for AWS AppConfig in CloudWatch Logs
-
Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the navigation pane, choose Logs, and then choose Log groups.
-
Choose the checkbox beside the AWS AppConfig log group.
-
Choose Actions, and then choose Create metric filter.
-
For Filter name, enter a name.
-
For Filter pattern, enter the following:
{ $.eventSource = "appconfig.amazonaws.com" }
-
(Optional) In the Test pattern section, choose your log group from the Select log data to test list. If CloudTrail hasn't logged any calls, you can skip this step.
-
Choose Next.
-
For Metric namespace, enter
AWS AppConfig
. -
For Metric name, enter
Calls
. -
For Metric value, enter
1
. -
Skip Default value and Unit.
-
For Dimension name, enter
operation
. -
For Dimension value, enter
$.eventName
.(Optional) You can enter a second dimension that includes the Amazon Resource Name (ARN) making the call. To add a second dimension, for Dimension name, enter
resource
. For Dimension value, enter$.resources[0].ARN
.Choose Next.
-
Review the details of the filter and Create metric filter.
(Optional) You can repeat this procedure to create a new metric filter for a specific error code like AccessDenied. If you do, enter the following details:
-
For Filter name, enter a name.
-
For Filter pattern, enter the following:
{ $.errorCode = "
codename
" }For example
{ $.errorCode = "
AccessDenied
" } -
For Metric namespace, enter
AWS AppConfig
. -
For Metric name, enter
Errors
. -
For Metric value, enter
1
. -
For Default value, enter a zero (0).
-
Skip Unit, Dimensions, and Alarms.
After CloudTrail logs API calls, you can view metrics in CloudWatch. For more information, see Viewing your metrics and logs in the console in the Amazon CloudWatch User Guide. For information about how to locate a metric you created, see Search for available metrics.
Note
If you set up the error metric with no dimension, as described here, you can view those metrics on the Metrics with no dimension page.
Creating an alarm for a CloudWatch metric
After you create metrics, you can create metric alarms in CloudWatch. For example, you can
create an alarm for the AWS AppConfig calls metric you created in the previous
procedure. Specifically, you can create an alarm for calls to the AWS AppConfig
StartConfigurationSession
API action that surpass a threshold. For
information about how to create an alarm for a metric, see Create a CloudWatch alarm based on a
static threshold in the Amazon CloudWatch User Guide. For information
about default limits for calls to the AWS AppConfig data plane, see Data plane default limits
in the Amazon Web Services General Reference.