7 Log Commands

The log commands manage the logs available under the CLI maintenance logs menu. For individual service log information, see the service API.

Manage Logs Commands

The following table show how to call the manage logs commands.

Table 7-1 Manage Logs Commands

Request Append to Path /api/log/v{1|2} Description

GET

Use only /api/log/v{1|2}

List the log service commands

GET

/logs

List all log types

GET

/logs/?start=index/time&limit=entry limit

Get log entries for the selected range

GET

/logs/alert

List all alert logs

GET

/logs/alert?start=index/time&limit=entry limit

Get log entries for the selected range

GET

/collect

Download a collection of all log entries

GET

/collect?start=index/time&limit=entry limit

Download a collection of log entries from a selected range

List Logs

This command lists all of the logs available on an appliance. Each log returns the number of entries in the log and a time stamp of the last entry.

Note:

The depth query parameter and the match_property-name=value query parameter are not supported.

Example Request:

GET /api/log/v1/logs HTTP/1.1
Authorization: Basic Tm8gcGVla2luZyE=
Host: zfs-storage.example.com:215
Accept: application/json

Example Result:

HTTP/1.1 200 OK
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 532
X-Zfssa-Api: 1.0

{
    "logs": [
        {
            "href": "/api/log/v1/logs/fault",
            "name": "faults",
            "size": 16,
            "updated": "20130614T22:51:48"
        },
        {
            "href": "/api/log/v1/logs/audit",
            "name": "audits",
            "size": 460149,
            "updated": "20130730T22:10:41"
        },
        {
            "href": "/api/log/v1/logs/alert",
            "name": "alerts",
            "size": 13054,
            "updated": "20130728T00:06:10"
        },
        {
            "href": "/api/log/v1/logs/phone-home",
            "name": "phone-home",
            "size": 249,
            "updated": "20130730T03:22:35"
        },
        {
            "href": "/api/log/v1/logs/system",
            "name": "system",
            "size": 344,
            "updated": "20130724T03:21:55"
        }
    ]
}

Get Log Entries

Log entries can be returned from the specified appliance log. Each log entry returns the date/time of the entry along with log specific content properties.

Note:

Depending on the number of logs, older log entries might not be available due to memory constraints. This same limit occurs in the BUI and CLI. To obtain all system logs, use the collect function described in Manage Logs Commands.
Parameter Description

start=index

Start returning logs from the given index/time

limit=number

Limit number of log entries returned

The start index defaults to the value of 0, which returns the first log that was generated. Negative values and values greater than or equal to the log size are not allowed. The start index can also be a time string; for example, 20130724T03:21:55.

Note:

REST only accepts UTC time. Time values that are older than one month from the current time are not accepted. Retrieval of older logs must use an index number for the start value. The limit value limits the number of logs returned for a given request. No more than the given limit value is returned.

Example Request:

GET /api/log/v1/logs/audit?limit=4&start=1000 HTTP/1.1
Authorization: Basic Tm8gcGVla2luZyE=
Host: zfs-storage.example.com:215
Accept: application/json

Example Result:

HTTP/1.1 200 OK
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
X-Zfssa-Api: development
Transfer-Encoding: chunked

{
    "logs": [
        {
            "address": "192.0.2.0",
            "annotation": "",
            "summary": "User logged in",
            "timestamp": "20131022T22:54:19",
            "user": "root"
        }, {
            "address": "192.0.2.0",
            "annotation": "",
            "summary": "Destroyed share \"zfs-storage-1:tst.volumes.py.34111.project/tst.volumes.py.34111.lun.7\"",
            "timestamp": "20131022T22:52:34",
            "user": "root"
        }, {
            "summary": "Joined workgroup \"RESTTESTWG\"",
            "timestamp": "20131022T22:54:23",
            "user": "<system>"
        }, {
            "address": "192.0.2.0",
            "annotation": "",
            "summary": "User logged in",
            "timestamp": "20131022T22:54:19",
            "user": "root"
        }
    ]
}

Download Logs

The download logs command returns a gzipped tar file containing all of the system logs. The file disposition name is set to logs.tar.gz. Because the data is created and streamed in real time, it is not possible to resume a download.

Download Log

If only one log type is desired to be downloaded, its name can be appended to the collect resource as shown in the table. The text of the log is streamed back to the client. If gzip compression is requested, the text stream is compressed with gzip. Other compression types are not supported and are ignored.