Skip to main content

Python Client for Netuitive Cloud

Project description

BuildStatus

https://coveralls.io/repos/github/Netuitive/netuitive-client-python/badge.svg?branch=master:target:https://coveralls.io/github/Netuitive/netuitive-client-python?branch=master
The Netuitive Python Client allows you to push data to Netuitive using Python. Netuitive provides an adaptive monitoring and analytics platform for cloud infrastructure and web applications.
For more information, check out the help docs or contact support.

The Netuitive Python Client can…

  • …create an element in Netuitive with the following data:
    • Element Name

    • Attributes

    • Tags

    • Metric Samples

    • Element relations

    • Location

    • Metric Tags

  • …create an event in Netuitive with the following data:
    • Element Name

    • Event Type

    • Title

    • Message

    • Level

    • Tags

    • Source

Using the Python Netuitive Client

Setup the Client

ApiClient = netuitive.Client(api_key='<my_api_key>')

Setup the Element

MyElement = netuitive.Element()

Add an Attribute

MyElement.add_attribute('Language', 'Python')

Add an Element relation

MyElement.add_relation('my_child_element')

Add a Tag

MyElement.add_tag('Production', 'True')

Add a Metric Sample

MyElement.add_sample('cpu.idle', 1432832135, 1, host='my_hostname')

Add a Metric Sample with a Sparse Data Strategy

MyElement.add_sample('app.zero', 1432832135, 1, host='my_hostname', sparseDataStrategy='ReplaceWithZero')

Add a Metric Sample with unit type

MyElement.add_sample('app.requests', 1432832135, 1, host='my_hostname', unit='requests/s')

Add a Metric Sample with utilization tag

MyElement.add_sample('app.requests', 1432832135, 1, host='my_hostname', tags=[{'utilization': 'true'}])

Add a Metric Sample with min/max values

MyElement.add_sample('app.percent_used', 1432832135, 50, host='my_hostname', unit='percent', min=0, max=100)

Send the Samples

ApiClient.post(MyElement)

Remove the samples already sent

MyElement.clear_samples()

Create an Event

MyEvent = netuitive.Event(hst, 'INFO', 'test event','this is a test message', 'INFO')

Send the Event

ApiClient.post_event(MyEvent)

Check that our local time is set correctly (returns True/False)

ApiClient.time_insync()

Example

The below example sets up the Netuitive Python client, creates an element (“MyElement”) with attributes, a relationship, and tags and then passes in some samples. After the element is posted, the samples are cleared, an event is created and posted.

import netuitive
import time

ApiClient = netuitive.Client(api_key='aaaa9956110211e594444697f922ec7b')

MyElement = netuitive.Element()

MyElement.add_attribute('Language', 'Python')
MyElement.add_attribute('app_version', '7.0')

MyElement.add_relation('my_child_element')

MyElement.add_tag('Production', 'True')
MyElement.add_tag('app_tier', 'True')

timestamp = int(time.mktime(time.gmtime()))
MyElement.add_sample('app.error', timestamp, 1, host='appserver01')
MyElement.add_sample('app.request', timestamp, 10, host='appserver01')

ApiClient.post(MyElement)

MyElement.clear_samples()

MyEvent = netuitive.Event('appserver01', 'INFO', 'test event','this is a test message', 'INFO')

ApiClient.post_event(MyEvent)

if ApiClient.time_insync():
    print('we have time sync with the server')

History

0.2.0 (2016-07-22)

  • sanitize metric names

0.1.6 (2016-05-20)

  • fix handling of http errors

0.1.5 (2016-05-03)

  • fix the internal version number

  • improve handling of http errors

0.1.4 (2016-04-07)

  • improve HTTP response error handling

  • Update Development Status to 4 - Beta

0.1.3 (2016-03-21)

  • Add user agent to time offset check

  • Better handling of null element ids

0.1.2 (2016-03-09)

  • Fix server time offset check

0.1.1 (2016-03-08)

  • Add server time offset check

  • Fix default event time

0.1.0 (2016-01-27)

  • Add metric tag support

  • Add min/max/avg/sum/cnt support

  • Add Element location support

  • Test re-factor

  • Increase test coverage

  • Fix for event support

0.0.9 (2015-12-03)

  • Add custom client string

  • Add relation support

0.0.8 (2015-10-16)

  • Add event support

  • Add Python 3 support

0.0.7 (2015-06-23)

  • Fix for Preventing duplicate metrics

0.0.6 (2015-06-23)

  • Add support for Spare Data Strategy and Unit settings for Metrics

  • Prevent duplicate metrics

  • Documentation improvements

0.0.5 (2015-06-12)

  • Element type is now easier to set

0.0.3 (2015-06-01)

  • Fixes for API URL setting

0.0.2 (2015-05-28)

  • First release on PyPI.

Project details


Download files

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

Source Distribution

netuitive-0.2.0.tar.gz (25.3 kB view hashes)

Uploaded Source

Built Distribution

netuitive-0.2.0-py2.py3-none-any.whl (11.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page