Skip to main content

Python API Wrapper for NewRelic API

Project description

# Pyrelic [![Build Status](](

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

Unfortunately, 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).

## Installation
$ pip install pyrelic

## Examples

from pyrelic import Client
from time import sleep

c = Client(account_id='12345', api_key='1234567890abcdef1234567890abcdef')

# Get some metric data
metrics = c.get_metric_data(['My Application'], ['Database/my_table/select', 'Database/my_table/update'], ['average_value'], '2012-03-28T15:48:00Z', '2012-03-29T15:48:00Z')

for metric in metrics:
if contains "select":
print "Average Select Time: %s" % metric.average_value
if contains "update":
print "Average Update Time: %s" % metric.average_value

# Careful of API timeouts!
metrics = c.get_metric_data(['My Application'], ['Database/my_table/select', 'Database/my_table/update'], ['average_value'], '2012-03-28T15:48:00Z', '2012-03-29T15:48:00Z')
except NewRelicApiRateLimitException as e:

# List some metrics
metrics = 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 have
applications = c.view_applications()

for application in applications:
print "Name: %s" %
print "ID: %s" % application.app_id
print "URL: %s" % application.url

# Delete your application
failed_deletions = c.delete_applications( {
'app_id': 1234,
'app': 'My Application'

if len(failed_deletions) is 0:
print "All applications deleted succesfully!"

## How to contribute

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Run the tests before making any changes (`make unit`)
4. Commit your changes (`git commit -am 'Add some feature'`)
5. Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request

## Contributors

[Ryan Gooler](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyrelic, version 0.5.3
Filename, size File type Python version Upload date Hashes
Filename, size pyrelic-0.5.3.tar.gz (235.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page