How can I create a custom metric watching EFS metered size in AWS Cloudwatch?AWS CloudWatch API: getting the database-wide metricsAWS cloudwatch custom metrics data not visibleQuery AWS CloudWatch custom metrics across dimensionsHow can we monitor a process with cloudwatchStopping EC2 instance when custom cloudwatch metric passes limitCreate a custom cloudwatch metric that calculates the %How do I Create a CloudWatch Email Alert With Custom Content?Custom Cloudwatch MetricsCloudWatch does not aggregate across dimensions for your custom metricsCloudWatch custom EC2 memory metric and alarm with AutoScaling policy
Is it better to have a 10 year gap or a bad reference?
Finding Greatest Common Divisor using LuaLatex
Why can't a country print its own money to spend it only abroad?
Plotting maxima within a simplex
Stellen - Putting, or putting away?
Which dice game has a board with 9x9 squares that has different colors on the diagonals and midway on some edges?
How do you structure large embedded projects?
Piece of fabric in planter, how to use it?
I am a dual citizen of United States and Mexico, can I use my Mexican license in california when visiting?
How can I show that the speed of light in vacuum is the same in all reference frames?
Is it better to merge "often" or only after completion do a big merge of feature branches?
Are there any English words pronounced with sounds/syllables that aren't part of the spelling?
Does switching on an old games console without a cartridge damage it?
Reissue US, UK, Canada visas in stolen passports
Would using carbon dioxide as fuel work to reduce the greenhouse effect?
Can a ring have no zero divisors while being non-commutative and having no unity?
Can a creature sustain itself by eating its own severed body parts?
Found old paper shares of Motorola Inc that has since been broken up
Reset Column Header Index
What would be the effects of (relatively) widespread precognition on the stock market?
Found more old paper shares from broken up companies
How to pass array of values in lualatex?
Monday's Blocking Donimoes Problem
Can I use Sitecore's Configuration patching mechanics for my Identity Server configuration?
How can I create a custom metric watching EFS metered size in AWS Cloudwatch?
AWS CloudWatch API: getting the database-wide metricsAWS cloudwatch custom metrics data not visibleQuery AWS CloudWatch custom metrics across dimensionsHow can we monitor a process with cloudwatchStopping EC2 instance when custom cloudwatch metric passes limitCreate a custom cloudwatch metric that calculates the %How do I Create a CloudWatch Email Alert With Custom Content?Custom Cloudwatch MetricsCloudWatch does not aggregate across dimensions for your custom metricsCloudWatch custom EC2 memory metric and alarm with AutoScaling policy
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Title pretty much says it all - Since the EFS metered size (usage) ist not a metric that I can use in Cloudwatch, I need to create a custom metric watching the last metered file size in EFS.
Is there any possiblity to do so? Or is there maybe a even better way to monitore the size of my EFS?
amazon-web-services amazon-cloudwatch amazon-efs
add a comment |
Title pretty much says it all - Since the EFS metered size (usage) ist not a metric that I can use in Cloudwatch, I need to create a custom metric watching the last metered file size in EFS.
Is there any possiblity to do so? Or is there maybe a even better way to monitore the size of my EFS?
amazon-web-services amazon-cloudwatch amazon-efs
add a comment |
Title pretty much says it all - Since the EFS metered size (usage) ist not a metric that I can use in Cloudwatch, I need to create a custom metric watching the last metered file size in EFS.
Is there any possiblity to do so? Or is there maybe a even better way to monitore the size of my EFS?
amazon-web-services amazon-cloudwatch amazon-efs
Title pretty much says it all - Since the EFS metered size (usage) ist not a metric that I can use in Cloudwatch, I need to create a custom metric watching the last metered file size in EFS.
Is there any possiblity to do so? Or is there maybe a even better way to monitore the size of my EFS?
amazon-web-services amazon-cloudwatch amazon-efs
amazon-web-services amazon-cloudwatch amazon-efs
asked Mar 26 at 13:23
DavidDavid
161 bronze badge
161 bronze badge
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I would recommend using a Lambda, running every hour or so and sending the data into CloudWatch.
This code gathers all the EFS File Systems and sends their size (in kb) to Cloudwatch along with the file system name. Modify it to suit your needs:
import json
import boto3
region = "us-east-1"
def push_efs_size_metric(region):
efs_name = []
efs = boto3.client('efs', region_name=region)
cw = boto3.client('cloudwatch', region_name=region)
efs_file_systems = efs.describe_file_systems()['FileSystems']
for fs in efs_file_systems:
efs_name.append(fs['Name'])
cw.put_metric_data(
Namespace="EFS Metrics",
MetricData=[
'MetricName': 'EFS Size',
'Dimensions': [
'Name': 'EFS_Name',
'Value': fs['Name']
],
'Value': fs['SizeInBytes']['Value']/1024,
'Unit': 'Kilobytes'
]
)
return efs_name
def cloudtrail_handler(event, context):
response = push_efs_size_metric(region)
print (
'EFS Names' : response
)
I'd also suggest reading up on the reference below for more details on creating custom metrics.
References
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
1
This looks great, but you might want also (or instead) want to graphSizeInBytes.ValueInStandard
andSizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.
– Michael - sqlbot
Mar 26 at 18:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55358277%2fhow-can-i-create-a-custom-metric-watching-efs-metered-size-in-aws-cloudwatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would recommend using a Lambda, running every hour or so and sending the data into CloudWatch.
This code gathers all the EFS File Systems and sends their size (in kb) to Cloudwatch along with the file system name. Modify it to suit your needs:
import json
import boto3
region = "us-east-1"
def push_efs_size_metric(region):
efs_name = []
efs = boto3.client('efs', region_name=region)
cw = boto3.client('cloudwatch', region_name=region)
efs_file_systems = efs.describe_file_systems()['FileSystems']
for fs in efs_file_systems:
efs_name.append(fs['Name'])
cw.put_metric_data(
Namespace="EFS Metrics",
MetricData=[
'MetricName': 'EFS Size',
'Dimensions': [
'Name': 'EFS_Name',
'Value': fs['Name']
],
'Value': fs['SizeInBytes']['Value']/1024,
'Unit': 'Kilobytes'
]
)
return efs_name
def cloudtrail_handler(event, context):
response = push_efs_size_metric(region)
print (
'EFS Names' : response
)
I'd also suggest reading up on the reference below for more details on creating custom metrics.
References
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
1
This looks great, but you might want also (or instead) want to graphSizeInBytes.ValueInStandard
andSizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.
– Michael - sqlbot
Mar 26 at 18:02
add a comment |
I would recommend using a Lambda, running every hour or so and sending the data into CloudWatch.
This code gathers all the EFS File Systems and sends their size (in kb) to Cloudwatch along with the file system name. Modify it to suit your needs:
import json
import boto3
region = "us-east-1"
def push_efs_size_metric(region):
efs_name = []
efs = boto3.client('efs', region_name=region)
cw = boto3.client('cloudwatch', region_name=region)
efs_file_systems = efs.describe_file_systems()['FileSystems']
for fs in efs_file_systems:
efs_name.append(fs['Name'])
cw.put_metric_data(
Namespace="EFS Metrics",
MetricData=[
'MetricName': 'EFS Size',
'Dimensions': [
'Name': 'EFS_Name',
'Value': fs['Name']
],
'Value': fs['SizeInBytes']['Value']/1024,
'Unit': 'Kilobytes'
]
)
return efs_name
def cloudtrail_handler(event, context):
response = push_efs_size_metric(region)
print (
'EFS Names' : response
)
I'd also suggest reading up on the reference below for more details on creating custom metrics.
References
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
1
This looks great, but you might want also (or instead) want to graphSizeInBytes.ValueInStandard
andSizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.
– Michael - sqlbot
Mar 26 at 18:02
add a comment |
I would recommend using a Lambda, running every hour or so and sending the data into CloudWatch.
This code gathers all the EFS File Systems and sends their size (in kb) to Cloudwatch along with the file system name. Modify it to suit your needs:
import json
import boto3
region = "us-east-1"
def push_efs_size_metric(region):
efs_name = []
efs = boto3.client('efs', region_name=region)
cw = boto3.client('cloudwatch', region_name=region)
efs_file_systems = efs.describe_file_systems()['FileSystems']
for fs in efs_file_systems:
efs_name.append(fs['Name'])
cw.put_metric_data(
Namespace="EFS Metrics",
MetricData=[
'MetricName': 'EFS Size',
'Dimensions': [
'Name': 'EFS_Name',
'Value': fs['Name']
],
'Value': fs['SizeInBytes']['Value']/1024,
'Unit': 'Kilobytes'
]
)
return efs_name
def cloudtrail_handler(event, context):
response = push_efs_size_metric(region)
print (
'EFS Names' : response
)
I'd also suggest reading up on the reference below for more details on creating custom metrics.
References
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
I would recommend using a Lambda, running every hour or so and sending the data into CloudWatch.
This code gathers all the EFS File Systems and sends their size (in kb) to Cloudwatch along with the file system name. Modify it to suit your needs:
import json
import boto3
region = "us-east-1"
def push_efs_size_metric(region):
efs_name = []
efs = boto3.client('efs', region_name=region)
cw = boto3.client('cloudwatch', region_name=region)
efs_file_systems = efs.describe_file_systems()['FileSystems']
for fs in efs_file_systems:
efs_name.append(fs['Name'])
cw.put_metric_data(
Namespace="EFS Metrics",
MetricData=[
'MetricName': 'EFS Size',
'Dimensions': [
'Name': 'EFS_Name',
'Value': fs['Name']
],
'Value': fs['SizeInBytes']['Value']/1024,
'Unit': 'Kilobytes'
]
)
return efs_name
def cloudtrail_handler(event, context):
response = push_efs_size_metric(region)
print (
'EFS Names' : response
)
I'd also suggest reading up on the reference below for more details on creating custom metrics.
References
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
edited Apr 11 at 7:12
slm
9,30810 gold badges67 silver badges84 bronze badges
9,30810 gold badges67 silver badges84 bronze badges
answered Mar 26 at 16:37
kenlukaskenlukas
2,0274 gold badges15 silver badges23 bronze badges
2,0274 gold badges15 silver badges23 bronze badges
1
This looks great, but you might want also (or instead) want to graphSizeInBytes.ValueInStandard
andSizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.
– Michael - sqlbot
Mar 26 at 18:02
add a comment |
1
This looks great, but you might want also (or instead) want to graphSizeInBytes.ValueInStandard
andSizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.
– Michael - sqlbot
Mar 26 at 18:02
1
1
This looks great, but you might want also (or instead) want to graph
SizeInBytes.ValueInStandard
and SizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.– Michael - sqlbot
Mar 26 at 18:02
This looks great, but you might want also (or instead) want to graph
SizeInBytes.ValueInStandard
and SizeInBytes.ValueInIA
, particularly since the cost of the two EFS storage classes is so different. docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html ...Also maybe run twice per hour to be sure you don't collide with the time when the hourly stats update, which isn't documented, or to cover for an occasional misfire.– Michael - sqlbot
Mar 26 at 18:02
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55358277%2fhow-can-i-create-a-custom-metric-watching-efs-metered-size-in-aws-cloudwatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown