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
ApiClient = netuitive.Client(api_key='<my_api_key>')
MyElement = netuitive.Element()
MyElement.add_attribute('Language', 'Python')
MyElement.add_relation('my_child_element')
MyElement.add_tag('Production', 'True')
MyElement.add_sample('cpu.idle', 1432832135, 1, host='my_hostname')
MyElement.add_sample('app.zero', 1432832135, 1, host='my_hostname', sparseDataStrategy='ReplaceWithZero')
MyElement.add_sample('app.requests', 1432832135, 1, host='my_hostname', unit='requests/s')
MyElement.add_sample('app.requests', 1432832135, 1, host='my_hostname', tags=[{'utilization': 'true'}])
MyElement.add_sample('app.percent_used', 1432832135, 50, host='my_hostname', unit='percent', min=0, max=100)
ApiClient.post(MyElement)
MyElement.clear_samples()
MyEvent = netuitive.Event(hst, 'INFO', 'test event','this is a test message', 'INFO')
ApiClient.post_event(MyEvent)
ApiClient.time_insync()
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')
Copyright 2015-2016 Netuitive, Inc. under [the Apache 2.0 license](LICENSE).