{% extends "rest_framework/api_basics.html" %} {% block description %}
General pages require credentials for any system or IMX_ADMIN.
Pages of a specific system require credentials for the system or IMX_ADMIN.
Getting a list of all systems being monitored by InfiniMetrics:
curl -u username:password https://infinimetrics/api/rest/systems/
Getting a single system with serial number 10017:
curl -u username:password https://infinimetrics/api/rest/systems/10017/
Getting any annotations defined for the system:
curl -u username:password https://infinimetrics/api/rest/systems/10017/annotations/
The default response format is JSON, so the following three commands are equivalent:
curl -u username:password https://infinimetrics/api/rest/systems/ curl -u username:password https://infinimetrics/api/rest/systems/?format=json curl -u username:password --header "Accept: application/json" https://infinimetrics/api/rest/systems/
The Accept header can include an indent media type parameter, in which case the returned JSON will be formatted nicely:
curl -u username:password --header "Accept: application/json; indent=4" https://infinimetrics/api/rest/systems/
To get a response in CSV format, use one of the following options:
curl -u username:password https://infinimetrics/api/rest/systems/?format=csv curl -u username:password --header "Accept: text/csv" https://infinimetrics/api/rest/systems/
Searching for a system with a specific name:
curl -u username:password https://infinimetrics/api/rest/systems/?name=mybox
Searching for annotations containing some text, sorting the results latest first:
curl -u username:password https://infinimetrics/api/rest/systems/10017/annotations/?description=like:backup&sort=-timestamp
For additional details see Filtering and Sorting.
Use a PATCH request to make changes to an existing system. The request payload can be sent as JSON,
in which case you must specify that the content type is application/json.
The credentials after the --user are for authentication against the system.
The credentials after the --data are the new credentials InfiniMetrics will use to monitor this system:
curl --user username:password \
--request PATCH \
--header "Content-Type: application/json" \
--data '{"api_username": "admin", "api_password": "g6BT0acS"}' \
https://infinimetrics/api/rest/systems/10017/
Alternatively you may use the application/x-www-form-urlencoded encoding, which is the default in curl:
curl --user username:password \
--request PATCH \
--data 'api_username=admin&api_password=g6BT0acS' \
https://infinimetrics/api/rest/systems/10017/
Send a POST request containing 3 fields:
curl --request POST \
-u username:password \
--header "Content-Type: application/json" \
--data '{"type": "Volume", "name": "my_volume", "polling_interval": 10}' \
https://infinimetrics/api/rest/systems/10017/monitored_entities/
curl --request POST \
-u username:password \
--header "Content-Type: application/json" \
--data '{"type": "Filesystem", "id_in_system": 95644, "polling_interval": 30}' \
https://infinimetrics/api/rest/systems/10017/monitored_entities/
Creating a new annotation is done with a POST request:
curl --request POST \
-u username:password \
--header "Content-Type: application/json" \
--data '{"description": "Starting database backup", "marker_style": "purple"}' \
https://infinimetrics/api/rest/systems/10017/annotations/
In case the annotation timestamp isn't specified, the current time and date is used.
Getting the latest 3 records collected for a monitored entity:
curl -u username:password https://infinimetrics/api/rest/systems/10017/monitored_entities/1/data/?sort=-timestamp&page_size=3
To download large amounts of data you need to write code that handles pagination. For maximum efficiency,
use CSV format and set the page_size to its maximum value (10000).
The following Python code demonstrates how to download all records between two dates and save them to a file:
{% include "rest_framework/example_data_download.py" %}
{% endblock %}