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;








3















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?










share|improve this question




























    3















    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?










    share|improve this question
























      3












      3








      3








      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 13:23









      DavidDavid

      161 bronze badge




      161 bronze badge






















          1 Answer
          1






          active

          oldest

          votes


















          3














          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





          share|improve this answer




















          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          3














          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





          share|improve this answer




















          • 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
















          3














          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





          share|improve this answer




















          • 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














          3












          3








          3







          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





          share|improve this answer















          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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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 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













          • 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








          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









          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.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript