Live tail Query API

Fetch your Live tail logs with an HTTP API. This API accepts the same query parameters as the previous V1 Query API.

Querying Live tail returns rows based on your query. Each request returns a pagination.next url which you can query for more logs. Note that the URL contains a cursor query that works only when you don't change any query parameters, otherwise the behavior is not defined.

Follow redirects

Make sure to follow redirects when using this API.
For example, use the -L option with curl.

GET https://logs.betterstack.com/api/v2/query/live-tail

Query parameters

source_ids
required string
query
string
batch
integer
from
string
to
string
order
string

Headers

Authorization
required string
200

Response body

{
  "data": [
    {
      "app": "sample_app",
      "source_id": "123",
      "dt": "2022-07-19 12:28:14.000000",
      "event.http_request_received.port": null,
      "event.http_response_sent.status": null,
      "message": "Hello, world!",
      "level": "debug",
      "context.runtime.thread_id": "70039367973540",
      "context.system.pid": "14",
      "context.http.path": null,
      "context.http.method": null,
      "context.http.host": null,
      "context.http.remote_addr": null
    },
    {
      "app": "sample_app",
      "source_id": "123",
      "dt": "2022-07-19 12:28:14.000000",
      "event.http_request_received.port": null,
      "event.http_response_sent.status": null,
      "message": "Hello, world!",
      "level": "debug",
      "context.runtime.thread_id": "70182641597580",
      "context.system.pid": "14",
      "context.http.path": null,
      "context.http.method": null,
      "context.http.host": null,
      "context.http.remote_addr": null
    }
  ],
  "pagination": {
    "next": "https://logs.betterstack.com/api/v2/query/live-tail?batch=100&cursor=MjE5PTI%3D&from=2022-07-18+12%3A29%3A14+UTC&order=newest_first&source_ids=123&to=2022-07-19+12%3A28%3A14+UTC"
  }
}

Example cURL

Example
curl -L --request GET \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "source_ids=$SOURCE_ID" \
  --data-urlencode "query=level=info" \
  https://logs.betterstack.com/api/v2/query/live-tail