Api clients / Ruby / V1 / Methods

Get Logs | Ruby API Client V1 (Deprecated)

This version of the Ruby API client has been deprecated in favor of the latest version of the Ruby API client.

Required API Key: any key with the logs ACL
Method signature
client.get_logs()
client.get_logs(Integer offset, Integer length)
client.get_logs(Integer offset, Integer length, String type)

About this method

Get the logs of the latest search and indexing operations.

Retrieve the logs of your last 1,000 API calls. This helps with real-time debugging of your application.

This method only returns the logs of the targeted cluster.

All logs have a seven-day retention period. After that, they’re no longer accessible from the API.

This API is counted in your operation quota but is not logged.

Examples

1
2
3
4
5
6
7
8
// Get last 10 log entries
$res = $client->getLogs();

// Get last 100 log entries
$res = $client->getLogs([
  'offset' => 0,
  'length' => 100
]);

Parameters

offset
type: integer
default: 0
Optional

Specify the first entry to retrieve (0-based, 0 is the most recent log entry).

length
type: integer
default: 10
Optional

Specify the maximum number of entries to retrieve starting at the offset. Maximum allowed value: 1,000.

type
type: string|enum
Optional

Type of logs to retrieve. Can be one of the following:

  • all: Retrieve all the logs.
  • query: Retrieve only the queries.
  • build: Retrieve only the build operations.
  • error: Retrieve only the errors.
requestOptions
type: key/value mapping
default: No request options
Optional

A mapping of request options to send along with the request.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

JSON format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "logs":[
      {
        "timestamp":"2017-12-29T18:15:57Z",
        "method":"POST",
        "answer_code":"200",
        "query_body":"\n{\n \"requests\": [\n  {\n   \"indexName\": \"best_buy\",\n   \"params\": \"query=&hitsPerPage=10&page=0&attributesToRetrieve=*&highlightPreTag=%3Cais-highlight-0000000000%3E&highlightPostTag=%3C%2Fais-highlight-0000000000%3E&getRankingInfo=1&facets=%5B%22brand%22%2C%22categories%22%2C%22free_shipping%22%2C%22type%22%5D&tagFilters=\"\n  }\n ]\n}\n",
        "answer":"\n{\n \"results\": [\n  {\n   \"hits\": [\n    {\n     \"name\": \"Amazon - Fire TV Stick\",\n     \"description\": \"Amazon Fire TV Stick connects to your TV's HDMI port. Just grab and go to enjoy Netflix, Prime Instant Video, Hulu Plus, YouTube.com, music, and much more.\",\n     \"brand\": \"Amazon\",\n     \"categories\": [\n      \"TV & Home Theater\",\n      \"Streaming Media Players\"\n     ],\n     \"hierarchicalCategories\": {\n      \"lvl0\": \"TV & Home Theater\",\n      \"lvl1\": \"TV & Home Theater > Streaming Media Players\"\n     },\n     \"type\": \"Streaming media plyr\",\n     \"price\": 39.99,\n     \"price_range\": \"1 - 50\",\n     \"image\": \"https:\/\/cdn-demo.algolia.com\/bestbuy\/9999119_sb.jpg\",\n     \"url\": \"http:\/\/www.bestbuy.com\/site\/amazon-fire-tv-stick\/9999119.p?id=1219460752591&skuId=9999119&cmp=RMX&ky=1uWSHMdQqBeVJB9cXgEke60s5EjfS6M1W\",\n     \"free_shipping\": false,\n     \"popularity\": 9843,\n     \"rating\": 4,\n     \"objectID\": \"9999119\"\n",
        "url":"\/1\/indexes\/*\/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%203.24.7%3BAlgolia%20Dashboard%201.0.0%3Breact-instantsearch%204.1.3%3BJS%20Helper%202.23.0&x-algolia-application-id=AJ0P3S7DWQ&x-algolia-api-key=ce11****************************",
        "ip":"84.14.205.82",
        "query_headers":"Host: c1-de-3.algolianet.com\nConnection: keep-alive\nContent-Length: 308\naccept: application\/json\nOrigin: https:\/\/www.algolia.com\nUser-Agent: Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/63.0.3239.84 Safari\/537.36\ncontent-type: application\/x-www-form-urlencoded\nReferer: https:\/\/www.algolia.com\/apps\/AJ0P3S7DWQ\/explorer\/browse\/best_buy\nAccept-Encoding: gzip, deflate, br\nAccept-Language: fr,en;q=0.9\n",
        "sha1":"44c168cea54d2deca9a4724559cf15eccf15cf3e",
        "nb_api_calls":"1",
        "processing_time_ms":"1",
        "query_nb_hits":"10500",
        "index":"demo_index",
        "inner_queries":[
            {
              "indexName":"best_buy",
              "queryID":313453231,
              "offset":0,
              "userToken":"user_1"
            }
        ]
      }
  ]
}

log object

timestamp
string

Timestamp in ISO-8601 format.

method
string

Rest type of the method.

answer_code
string

HTTP response code.

query_body
string

Request body. It’s truncated after 1000 characters.

answer
string

Answer body. It’s truncated after 1000 characters.

url
string

Request URL.

ip
string

Client ip of the call.

query_headers
string

Request Headers (API Key is obfuscated).

sha1
string

SHA1 ID of entry.

nb_api_calls
string

Number of API calls.

processing_time_ms
string

Processing time for the query. This does not include network time.

query_nb_hits
string

Number of hits returned for the query.

exhaustive
boolean

Exhaustive flags used during the query.

index
string

Index name of the log.

inner_queries
object[]

Contains an object for each performed query with the indexName, queryID, offset, and userToken.

Did you find this page helpful?