pyrelic

New Relic Python API
Download

pyrelic Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Freeware
  • Price:
  • FREE
  • Publisher Name:
  • Andrew Gross
  • Publisher web site:
  • http://github.com/andrewgross/

pyrelic Tags


pyrelic Description

pyrelic is a NewRelic client library written in Python (since not all of us use Ruby).The documentation for this library is included in the appropriate 'doc' strings but it was derived by examining the New Relic Ruby API located at:https://github.com/newrelic/newrelic_apiUnfortunately, while the documentation for their API is very solid, the implementation details are pretty sparse since they are centered around the Rails Active Resource helper library. This made it a bit trickier to reproduce the API in python but it seems to have worked out so far (with some querks).Installationpip install pyrelicExamplesfrom pyrelic import Clientfrom time import sleepc = Client(account_id='12345', api_key='1234567890abcdef1234567890abcdef')# Get some metric datametrics = c.get_metric_data(, , , '2012-03-28T15:48:00Z', '2012-03-29T15:48:00Z')for metric in metrics: if metric.name contains "select": print "Average Select Time: %s" % metric.average_value if metric.name contains "update": print "Average Update Time: %s" % metric.average_value# Careful of API timeouts!try: metrics = c.get_metric_data(, , , '2012-03-28T15:48:00Z', '2012-03-29T15:48:00Z')except NewRelicApiRateLimitException as e: sleep(e.timeout)# List some metricsmetrics = c.get_metric_list('123456', re='Database')for k,v in metrics.iteritems(): print "Metric Name: %s" % k print "Available Fields: %s " % v# Figure out what applications you haveapplications = c.view_applications()for application in applications: print "Name: %s" % application.name print "ID: %s" % application.app_id print "URL: %s" % application.url# Delete your applicationfailed_deletions = c.delete_applications( { 'app_id': 1234, 'app': 'My Application' })if len(failed_deletions) is 0: print "All applications deleted succesfully!"Product's homepage


pyrelic Related Software