Netdata/MongoDB/API: Difference between revisions
From charlesreid1
(Created page with "The Netdata url schema exposes all metrics being measured by Netdata as a JSON-exportable REST url. To obtain the data that Netdata is reading, then, is a simple matter of ma...") |
No edit summary |
||
| Line 1: | Line 1: | ||
The Netdata url schema exposes all metrics being measured by Netdata as a JSON-exportable REST url. | The Netdata url schema exposes all metrics being measured by Netdata as a JSON-exportable REST url. | ||
==querying netdata API== | |||
To obtain the data that Netdata is reading, then, is a simple matter of making a URL request and translating the result into JSON. This is a breeze with the Python 3 requests library: | To obtain the data that Netdata is reading, then, is a simple matter of making a URL request and translating the result into JSON. This is a breeze with the Python 3 requests library: | ||
| Line 7: | Line 9: | ||
my_url = 'http://10.3.0.1:19999/api/v1/allmetrics?format=json&help=yes' | my_url = 'http://10.3.0.1:19999/api/v1/allmetrics?format=json&help=yes' | ||
r = requests.get(url=my_url) | r = requests.get(url=my_url) | ||
# dump resulting json | |||
with open(output.json','w') as f: | |||
json.dump( r.json(), f ) | |||
# print resulting json | |||
print(r.json()) | print(r.json()) | ||
</pre> | </pre> | ||
This displays a huge dictionary full of key-value pairs - all the quantities netdata is monitoring. | This displays a huge dictionary full of key-value pairs - all the quantities netdata is monitoring. | ||
Revision as of 03:45, 11 February 2018
The Netdata url schema exposes all metrics being measured by Netdata as a JSON-exportable REST url.
querying netdata API
To obtain the data that Netdata is reading, then, is a simple matter of making a URL request and translating the result into JSON. This is a breeze with the Python 3 requests library:
import requests
my_url = 'http://10.3.0.1:19999/api/v1/allmetrics?format=json&help=yes'
r = requests.get(url=my_url)
# dump resulting json
with open(output.json','w') as f:
json.dump( r.json(), f )
# print resulting json
print(r.json())
This displays a huge dictionary full of key-value pairs - all the quantities netdata is monitoring.