library
turbot/aws_thrifty

Detect & correct EBS volumes with low usage

Overview

EBS volumes with low usage may be indicative that they're no longer required, these should be reviewed.

This query trigger detects EBS volumes with low average usage and then either sends a notification or attempts to perform a predefined corrective action.

Getting Started

By default, this trigger is disabled, however it can be configred by setting the below variables

  • ebs_volumes_with_low_usage_trigger_enabled should be set to true as the default is false.
  • ebs_volumes_with_low_usage_trigger_schedule should be set to your desired running schedule
  • ebs_volumes_with_low_usage_default_action should be set to your desired action (i.e. "notify" for notifications or "delete_volume" to update the volume).

Then starting the server:

flowpipe server

or if you've set the variables in a .fpvars file:

flowpipe server --var-file=/path/to/your.fpvars

Query

with ebs_usage as (
select
account_id,
_ctx,
region,
volume_id,
round(avg(max)) as avg_max
from
(
(
select
partition,
account_id,
_ctx,
region,
volume_id,
cast(maximum as numeric) as max
from
aws_ebs_volume_metric_read_ops_daily
where
date_part('day', now() - timestamp) <= 30
)
union
(
select
partition,
account_id,
_ctx,
region,
volume_id,
cast(maximum as numeric) as max
from
aws_ebs_volume_metric_write_ops_daily
where
date_part('day', now() - timestamp) <= 30
)
) as read_and_write_ops
group by
1,
2,
3,
4,
5
)
select
concat(volume_id, ' [', region, '/', account_id, ']') as title,
volume_id,
region,
_ctx ->> 'connection_name' as cred
from
ebs_usage
where
avg_max <= 100 :: int

Schedule

15m