Example: Log operations using REST APIs
Event logs
A GET request to
/rest/v1/logs/event
URI returns all entries from all the event logs on the switch, including logs from internal processes.
The information returned by this request was not optimized for human readability. If you want to examine the log entries, Hewlett Packard Enterprise recommends that you use the Web UI. The Web UI also provides a method to export log entries.
In the following example, the
MESSAGE_ID
parameter filters the output to include event log messages only:
50c0fa81c2a545ec982a54293f1b1945
identifies event log messages from the active management module.73d7a43eaf714f97bbdf2b251b21cade
identifies event log messages from the standby management module. Not all switches have a standby management module.
Example method and URI:
GET "https://192.0.2.5/rest/v1/logs/event?
limit=1000&
priority=4&
since=24%20hour%20ago&
MESSAGE_ID=50c0fa81c2a545ec982a54293f1b1945,73d7a43eaf714f97bbdf2b251b21cade"
Example curl command:
$ curl -k --noproxy 192.0.2.5 GET \
-b /tmp/primary_auth_cookie \
"https://192.0.2.5/rest/v1/logs/event?
limit=1000&
priority=4&
since=24%20hour%20ago&
MESSAGE_ID=50c0fa81c2a545ec982a54293f1b1945,73d7a43eaf714f97bbdf2b251b21cade"
Accounting (audit) logs
A GET request to
/rest/v1/logs/audit
URI returns all entries from the accounting logs on the switch.
For a list of supported query parameters, see the ArubaOS-CX REST API Reference.
Example method and URI:
GET "https://192.0.2.5/rest/v1/logs/audit?
since=24%20hour%20ago&
usergroup=administrators&
session=CLI"
Example curl command:
$ curl -k --noproxy 192.0.2.5 GET \
-b /tmp/primary_auth_cookie \
"https://192.0.2.5/rest/v1/logs/audit?
since=24%20hour%20ago&
usergroup=administrators&
session=CLI"