Application Logs

Application Logs

Overview

When Summit Applications run, we keep logs of everything they do. This endpoint will allow you to view the logs for your own applications, including both our system-generated logs (which are generated whenever you use a Summit library function, like channel.say() or http.get()) and your own log commands (generated by the summit.log library).

Currently, this endpoint requires you to filter by channel_id. These values can be found at the /channel endpoint on each call, and will allow you to view a sequential log of everything that happened. Read on to see the options available to you for querying this data.

Authentication

The Summit REST API uses HTTP Basic Authentication. You can generate an API key and secret at platform.corvisacloud.com, in Access > API Keys.

Endpoint URL

https://api.us1.corvisa.io/latest/application_logs

Only GET requests are allowed for this endpoint. A GET request will return your application logs.

GET

Headers

Content-Type: application/json

Query Parameters

  • dir “asc”|“desc” (Default= “asc”) : The direction of the sort. Must be either “asc” or “desc”.
  • sort string (Default= “timestamp”) : The field to sort on. Must correspond to one of the following fields: call_id, channel_id, domain_id, level, timestamp.
  • channel_id UUID (required) : The UUID of the channel. Can be found at /channel.
  • level integer : The level of the log message. Level 7 is “debug”, 6 is “info”, 4 is “warning”, and 3 is “error”.
  • message string : The actual log message. You should URL encode any special characters, i.e. /application_logs?message={hello%20world}.
  • timestamp DateTime : The time of the message. When querying, you should use the ISO-8601 format, i.e. timestamp__lt=2014-11-21T10:44:40.005-0600. All times returned by this API will be UTC.

Allowed Query operators

Some of the fields allow some extra query operators.

level and timestamp allow the following:

  • lt : Less than. Example: /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__lt=5
  • le : Less than or equal. Example: /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__le=5
  • gt : Greater than. Example: /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__gt=5
  • ge : Greater than or equal. Example: /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__ge=5
  • ne : Not equal. Example: /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__ne=5

You can specify multiple operators for the same field to create ranges. For example, you could do /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__gt=4&level__lt=7 to only show objects with a level between 4 and 7. Just be sure you don’t specify multiple options for the same bound (so, you can’t use ge and gt on the same parameter in the same query).

The message field only allows the standard equality operator, like /application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&message=my%20terms. This currently will only return items that match the exact text of your query. If you include quotes in the parameter (like message="hi there"), it would only match a message with those quotes in it. You should URL encode any non-alpha characters (such as spaces) instead, as in the example above where we replace a space with %2b.

Simple GET Example

curl -X GET --user YOUR_KEY -H "Content-Type: application/json" https://api.us1.corvisa.io/latest/application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556

Response

{
    meta: {
        sort: "timestamp",
        start: 0,
        total: 3,
        limit: 0,
        dir: "asc"
    },
    data: [
        {
            level: 7,
            timestamp: "2014-11-20T16:24:02.153Z",
            call_id: "0149ce0c-5ede-0467-890d-bb5ac73187d4",
            channel_id: "bb44d90b-f2a8-43f9-80c8-110c25462556",
            message: "Executing command: channel.say(u'hello world', [])",
            domain_id: "77870255-f1ed-4c38-a1cd-3ae9d4a5a2fd"
        },
        {
            level: 6,
            timestamp: "2014-11-20T16:31:26.895Z",
            call_id: "0149ce0c-5ede-0467-890d-bb5ac73187d4",
            channel_id: "bb44d90b-f2a8-43f9-80c8-110c25462556",
            message: "Executing command: channel.say(u'Log begin', [])",
            domain_id: "77870255-f1ed-4c38-a1cd-3ae9d4a5a2fd"
        },
        {
            level: 6,
            timestamp: "2014-11-20T16:32:38.054Z",
            call_id: "0149ce0c-5ede-0467-890d-bb5ac73187d4",
            channel_id: "bb44d90b-f2a8-43f9-80c8-110c25462556",
            message: "Executing command: channel.hangup(None, [])",
            domain_id: "77870255-f1ed-4c38-a1cd-3ae9d4a5a2fd"
        }
    ]
}

In this response, you can see the meta object which contains metadata about the query (such as sort info, total item count, etc.), and the data object which contains the actual query output.

The example is simple, but many other queries could be applied to this same data set to narrow down your view. Some examples:

Only show logs that are level 6 or lower (so, filter out Debug messages):

/application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&level__le=6

Sort by level (ascending) instead of timestamp:

/application_logs?channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&sort=level&dir=asc

Filter by channel_id, then narrow down only items happening before a specific date:

/application_logs?timestamp__lt=2014-11-21T10:44:40.005-0600&channel_id=bb44d90b-f2a8-43f9-80c8-110c25462556&sort=timestamp&dir=asc