Example: Log operations using REST APIs

Event logs

A GET request to/rest/v10.04/logs/eventURI返回所有条目的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 Enterpriserecommends that you use the Web UI. The Web UI also provides a method to export log entries.

In the following example, theMESSAGE_IDparameter filters the output to include event log messages only:

  • 50c0fa81c2a545ec982a54293f1b1945identifies event log messages from the active management module.

  • 73d7a43eaf714f97bbdf2b251b21cadeidentifies 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/v10.04/logs/event? limit=1000& priority=4& since=24%20hour%20ago& MESSAGE_ID=50c0fa81c2a545ec982a54293f1b1945,73d7a43eaf714f97bbdf2b251b21cade"

Example curl command:

$curl --noproxy 192.0.2.5 -k GET \ -b /tmp/primary_auth_cookie \ "https://192.0.2.5/rest/v10.04/logs/event? limit=1000& priority=4& since=24%20hour%20ago& MESSAGE_ID=50c0fa81c2a545ec982a54293f1b1945,73d7a43eaf714f97bbdf2b251b21cade"

Accounting (audit) logs

A GET request to the/rest/v10.04/日志/审计URI returns all entries from the accounting logs on the switch.

For a list of supported query parameters, see theAOS-CXREST API Reference.

Example method and URI:

GET "https://192.0.2.5/rest/v10.04/日志/审计? since=24%20hour%20ago& usergroup=administrators& session=CLI"

Example curl command:

$curl --noproxy 192.0.2.5 -k GET \ -b /tmp/primary_auth_cookie \ "https://192.0.2.5/rest/v10.04/日志/审计? since=24%20hour%20ago& usergroup=administrators& session=CLI"