Query device log

Last Updated on : 2023-12-07 03:33:52download

Query device operation history records based on conditions.

API address

GET: /v1.0/devices/{device_id}/logs

Request parameter

Parameter nameTypeINRequiredDescription
device_idStringuritrueDevice ID
codesStringqueryfalseThe function points supported by the device. It supports multiple function points query, separated by a comma (,), the default is empty
typeStringquerytrueTypes supported by log query. Supports query of multiple event types, separated by commas (,), must be transmitted. (1 online, 2 offline, 3 device activation, 4 device reset, 5 instructions Issue, 6 firmware upgrade, 7 data point report, 8 device semaphore, 9 device restart, 10 timing information)
start_row_keyStringqueryfalseFree version parameter, query Hbase row key. The default value is empty
start_timeLongquerytrueThe start timestamp of the query, 13 digits
end_timeLongquerytrueThe end timestamp of the query, 13 digits
query_typeIntegerqueryfalseQuery type, the default is 1, (1 free version, 2 paid version)
last_row_keyStringqueryfalsePaging parameters of the paid version, the row key of the last piece of data. The default value is empty, check the first page, the paid version must be passed
last_event_timeLongqueryfalsePaging parameters of the paid version, the event time of the last piece of data (the default is the first page of the empty search, the paid version must be transmitted)
sizeIntegerqueryfalseThe size of the number of logs to be queried (the default is 20)

Return parameter

Parameter nameTypeDescription
resultDeviceLogResultRes

Description of result

Parameter nameTypeDescription
device_idStringDevice ID
has_nextBooleanIs there a next one, true yes, false no
current_row_keyStringFree version parameter, the current row key of Hbase.
next_row_keyStringFree version parameter, the next Hbase row key that satisfies the query condition. If the return value is null, it means that there is no next log that meets the query condition.
logsListLog message body
countLongPaid version parameters, the total number of logs that meet the query conditions

Description of logs

Parameter nameTypeDescription
codeStringFunction Point Code
valueObjectFunction point value
event_timeLongTime stamp when the event occurred
event_fromStringThe source of the event trigger, (1 device itself, 2 client instructions, 3 third-party platforms, 4 cloud instructions, -1 unknown)
event_idShortType of event, (1 online, 2 offline, 3 device activation, 4 device reset, 5 command issuance, 6 firmware upgrade, 7 data point report, 8 device semaphore, 9 device restart, 10 Timing information)
rowStringPaid version parameter, which is the current Hbase row key
statusStringThe data is valid and has not been deleted. The default value is '1'

Request example

GET: /v1.0/devices/6c9395918f4f4d85d8****/logs?end_time=1699433821000&start_time=1699433221000&type=1,2,7

Return example

{
    "tid": "a45cea067e1411eeaf49161d7283****",
    "result": {
        "current_row_key": "ZWM1N2U0MzQxd3htOGQ1OGQ0ZjRmODE5NTkzOWM2XzkyMjMzNzAzMzc0MjEwMTU4NjFf****",
        "device_id": "6c9395918f4f4d85d8****",
        "next_row_key": "ZWM1N2U0MzQxd3htOGQ1OGQ0ZjRmODE5NTkzOWM2XzkyMjMzNzAzMzc0MjExMjc4NDVf****",
        "has_next": true,
        "logs": [
            {
                "code": "target_dis_closest",
                "event_from": "1",
                "event_id": 7,
                "value": "202",
                "event_time": 1699433759946,
                "status": "1"
            },
            {
                "code": "target_dis_closest",
                "event_from": "1",
                "event_id": 7,
                "value": "210",
                "event_time": 1699433758927,
                "status": "1"
            }
        ]
    },
    "t": 1699433761797,
    "success": true
}

Error code

For more information, see error code.