Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python
import sys
from dlcli import api
'''
Returns a sum of the number of agents that have returned the base.count metric in the last minute.
You will need to update the TAG, org, account and key variables in the settings below.
'''
# Settings
TAG = 'mytag'
settings = {
'url': 'https://app.dataloop.io/api/v1',
'org': 'myorg',
'account': 'myaccount',
'key': 'myapikey',
}
try:
count = 0
for series in api.series.get_tag_series(tag=TAG, metric='base.count', resolution='30', period='60', **settings):
count += int(series['points'][0]['avg'])
print "OK | count=%d;;;;" % count
sys.exit(0)
except Exception, e:
print "FAIL! %s" % e
sys.exit(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment