steampipe plugin install aws

Table: aws_ec2_instance_metric_cpu_utilization_hourly - Query AWS EC2 Instance Metrics using SQL

The AWS EC2 Instance Metrics service provides insights into the performance of your EC2 instances. It allows you to monitor CPU utilization in an hourly manner using SQL queries. This can assist in identifying performance bottlenecks and optimizing resource usage for your EC2 instances.

Table Usage Guide

The aws_ec2_instance_metric_cpu_utilization_hourly table in Steampipe provides you with information about the CPU Utilization metrics of EC2 instances in AWS. This table enables you as a DevOps engineer, system administrator, or other technical professional to query CPU utilization metrics on an hourly basis. This can be useful for you in monitoring system performance, identifying potential bottlenecks, and planning for capacity. The schema outlines the various attributes of the EC2 instance CPU utilization metrics for you, including the instance ID, timestamp, maximum, minimum, and average CPU utilization.

The aws_ec2_instance_metric_cpu_utilization_hourly table provides you with metric statistics at 1 hour intervals for the most recent 60 days.

Examples

Basic info

Explore which instances in your AWS EC2 service are experiencing fluctuating CPU utilization over time. This allows you to pinpoint specific locations where performance optimization may be needed to improve overall efficiency.

select
instance_id,
timestamp,
minimum,
maximum,
average,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
order by
instance_id,
timestamp;
select
instance_id,
timestamp,
minimum,
maximum,
average,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
order by
instance_id,
timestamp;

CPU Over 80% average

Identify instances where EC2 instances have an average CPU utilization exceeding 80%. This can help in monitoring and optimizing resource usage, ensuring efficient performance of your AWS infrastructure.

select
instance_id,
timestamp,
round(minimum :: numeric, 2) as min_cpu,
round(maximum :: numeric, 2) as max_cpu,
round(average :: numeric, 2) as avg_cpu,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
where
average > 80
order by
instance_id,
timestamp;
select
instance_id,
timestamp,
round(minimum, 2) as min_cpu,
round(maximum, 2) as max_cpu,
round(average, 2) as avg_cpu,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
where
average > 80
order by
instance_id,
timestamp;

CPU hourly average < 1%

Determine the areas in which your AWS EC2 instances' CPU utilization is less than 1% on average per hour. This can help you identify underutilized resources and optimize your AWS usage for cost-effectiveness.

select
instance_id,
timestamp,
round(minimum :: numeric, 2) as min_cpu,
round(maximum :: numeric, 2) as max_cpu,
round(average :: numeric, 2) as avg_cpu,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
where
average < 1
order by
instance_id,
timestamp;
select
instance_id,
timestamp,
round(minimum, 2) as min_cpu,
round(maximum, 2) as max_cpu,
round(average, 2) as avg_cpu,
sample_count
from
aws_ec2_instance_metric_cpu_utilization_hourly
where
average < 1
order by
instance_id,
timestamp;

Schema for aws_ec2_instance_metric_cpu_utilization_hourly

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The AWS Account ID in which the resource is located.
averagedouble precisionThe average of the metric values that correspond to the data point.
instance_idtextThe ID of the instance.
maximumdouble precisionThe maximum metric value for the data point.
metric_nametextThe name of the metric.
minimumdouble precisionThe minimum metric value for the data point.
namespacetextThe metric namespace.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
regiontextThe AWS Region in which the resource is located.
sample_countdouble precisionThe number of metric values that contributed to the aggregate value of this data point.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
sumdouble precisionThe sum of the metric values for the data point.
timestamptimestamp with time zoneThe time stamp used for the data point.
unittextThe standard unit for the data point.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws

You can pass the configuration to the command with the --config argument:

steampipe_export_aws --config '<your_config>' aws_ec2_instance_metric_cpu_utilization_hourly