How can I filter Enhanced Monitoring CloudWatch logs to generate automated custom metrics for Amazon RDS?

3 minutos de lectura
0

How can I filter Enhanced Monitoring CloudWatch Logs to generate automated custom metrics for Amazon Relational Database Service (Amazon RDS)?

Short description

Enhanced Monitoring for RDS provides the following OS metrics:

  • Free Memory
  • Active Memory
  • Swap Free
  • Processes Running
  • File System Used

You can use these metrics to understand the environment's performance, and these metrics are ingested by Amazon CloudWatch Logs as log entries. You can use CloudWatch to create alarms based on metrics. These alarms run actions, and you can publish these metrics from within your infrastructure, device, or application into CloudWatch as a custom metric. By using Enhanced Monitoring and CloudWatch together, you can automate tasks by creating a custom metric for the CloudWatch Logs RDS ingested date from the Enhanced Monitoring metrics.

Resolution

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

Create a custom metric using filters on a log group

Note: These steps require that you enable Enhanced Monitoring in your RDS DB instance. For more information, see Monitoring an Amazon RDS DB instance.

1.    Enable Enhanced Monitoring.

2.    Open the Amazon CloudWatch console, and then choose Log groups from the navigation pane.

3.    Filter for RDSOSMetrics from the list of Log Groups, and then choose Actions.

4.    Choose Create Metric Filter, and then enter a Filter Pattern term for your RDS DB instance. For example:

DISK UTILIZATION: { $.diskIO[0].writeKbPS="0.00"}
DISK WRITE KBPS : { $.diskIO[0].util="0.00"}
DISK READ KBPS : { $.diskIO[0].readKbPS="0.00"}
DISK WRITE IOPS : { $.diskIO[0].writeKbPS="0.00"}

Note: Be sure to update 0.00 to the value that you want to measure.

5.    Select the Log Data to test, and then choose Test Pattern.

6.    Choose Next.

7.    Enter a Filter Name, and then select a Metric Namespace and Metric Name.

8.    Enter a Metric Value—for example, $.cpuUtilization.idle—and then choose Create Filter.

Repeat these steps for each additional metric that you add.

Automation

There are more than 60 monitoring metrics per RDS DB instance, and you can use a script to automate this process. See the GitHub repository for rds-support-tools for an example script that uses an RDS for MySQL DB instance that works with the following engines:

  • MySQL
  • MariaDB
  • Amazon Aurora (MySQL and PostgreSQL)
  • PostgreSQL

Specify the RDS DB instance that has Enhanced Monitoring enabled and the namespace where you want these metrics to reside—optionally, you can add the names of the metrics and the Region. If no optional fields are specified, the script considers all the metrics to publish, and then uses the Region that is specified by default in the file .aws/config using the AWS Command Line Interface (AWS CLI).

Note: The script doesn't create metrics for process list, so you might need to create filters manually, depending on the process that you want to display.

The names of the metrics must be specified by the following pattern:

group.metricname

The following sample code illustrates a call to enable this metric for cpuUtilization.idle and diskIO.readKbPS:

python RDSCreateMetricsFromEnhancedMonitoring.py --rds_instance mysqltest --namespace MySQL --metrics_to_filter cpuUtilization.idle diskIO.readKb

You can then create alarms for these custom metrics. For more information, see Using Amazon CloudWatch alarms.


Related information

Enhanced Monitoring

Amazon RDS database log files

OFICIAL DE AWS
OFICIAL DE AWSActualizada hace 3 años