Follow redirects
Make sure to follow redirects when using this API.
For example, use the -L
option with curl
.
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.
Make sure to follow redirects when using this API.
For example, use the -L
option with curl
.
Query parameters
Numberic value; Comma-separated list of sources you want to query.
Filter logs with your query. Use the same query as you would in Live tail. Read more about Live tail Query Language.
How many rows do you want to return? Accepts a range of 50-1000. Default: 100 rows.
Start of time range for the log query (ISO8601-formatted string: 2022-07-19T13:32:56+0000). Default: 30 minutes before to
. If to
is not specified then 30 minutes ago.
End of time range for the log query (ISO8601-formatted string: 2022-07-19T13:32:56+0000). Default: 30 minutes after from
. If from
is not specified then current time.
In what order do you want your logs? Possible values: newest_first
, oldest_first
. Default: newest_first
Headers
Bearer $TOKEN
Returned rows
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://telemetry.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"
}
}
curl -L --request GET \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "source_ids=$SOURCE_ID" \
--data-urlencode "query=level=info" \
https://telemetry.betterstack.com/api/v2/query/live-tail