Available Storage on FSx

0

I am using the CLI and Boto3 trying to get the current available storage for an FSx. Using the describe_file_systems function I can get the capacity but I am looking to get either current storage or available storage. How can I get one of these items programmatically?

asked a year ago384 views
2 Answers
0

The documentation here suggests that "describe-file-systems" can be used to check the status of the file.
https://docs.aws.amazon.com/fsx/latest/WindowsGuide/file-system-lifecycle-states.html

Since there is no option to filter by status in the request, we can use an if statement to display only those whose "Lifecycle" is "AVAILABLE".
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/fsx/client/describe_file_systems.html

This is a sample, but I thought the following would show only the available file storage capacity.

import boto3

client = boto3.client('fsx')

response = client.describe_file_systems()

file_systems_list = response['FileSystems']

for file_system in file_systems_list:
  if file_system['Lifecycle'] == 'AVAILABLE':
    print(file_system['FileSystemId'])
    print(file_system['StorageCapacity'])
profile picture
EXPERT
answered a year ago
0

Hi,

You can get this information from CloudWatch Metrics programmatically.

Documentation on how you can get this with the CLI is available here:

https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html

The metric names will differ slightly based on which FSx you are using. You can list the available metrics using aws cloudwatch list-metrics --namespace AWS/FSx

Below is an example for FSx ONTAP, which will show the minimum storage used in the past 24hrs, you can change your start / end time and period to suit your needs.

aws cloudwatch get-metric-statistics --namespace AWS/FSx --metric-name StorageUsed --start-time "$(date -d '-1 day' '+%F %T')" --end-time "$(date -d '-1 hour' '+%F %T')" --period 86400 --statistics Minimum --region
 eu-west-2 --dimensions Name=FileSystemId,Value=<<File System ID HERE>>
AWS
Tom-B
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions