Query Graphite DB using Powershell

by Frequent Contributor on ‎2017-04-11 09:58 AM

Recently I came across querying the graphite db of a customer to get raw performance data. Formerly the customer regularly gathered the data for its 7mode systems about the cifs and nfs iops in a particular time frame from Performance Advisor. The data is used to check the amount of IOPS for each controller. For cDOT there is currently no report and the raw data from OPM is not detailed enough. So the aim was to extract the raw data from its graphite / grafana source where all cDOT Systems are monitored with a minute interval.

 

So I wrote two functions to get the data from the graphite db and convert it into a custom powershell object. The resulting object can then easily be converted to a csv file by piping the output to the export-csv cmdlet for example. However, the custom object can be used for any other further development in powershell.

 

Thought I'd share these functions as someone else might have the need to query the graphite db from powershell. The first function invokes a web request to get the raw data from the database in json format. The second function converts the json output into a custom powershell object.

 

There are parameters for the graphite db query function to specify the target and from and until dates. For further details please see the comment-based help in the powershell code.

 

For the complete documentation of the graphite api please see 

http://graphite.readthedocs.io/en/latest/render_api.html

 

If you save the attached text file as .psm1 file you can easily use the functions by importing the module with the import-module cmdlet.

 

Happy powershell scripting! 

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.