Dashboards Query API

Run Dashboard metric queries with an HTTP API.

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/dashboards

Query parameters

source_ids
required string
query
required string
from
string
to
string

Headers

Authorization
required string
200

Response body

{"time":"2024-07-01 05:50:00","message":"Hello, world!"}
{"time":"2024-06-30 00:00:00","message":"Hello, you!"}
{"time":"2024-06-30 00:00:00","message":"Hello, me!"}

Example cURL

Example
curl -L --request GET \
  --header "Authorization: Bearer $TOKEN" \
  --data-urlencode "source_ids=$SOURCE_ID" \
  --data-urlencode "query=SELECT {{time}} AS time, countMerge(events_count) AS value, level AS series FROM {{source}} WHERE time BETWEEN {{start_time}} AND {{end_time}} GROUP BY time, series" \
  https://logs.betterstack.com/api/v2/query/dashboards

Adjusting the response format

By default rows are returned in the ClickHouse JSONEachRow format, you can change this by adding a FORMAT clause to you query.

See the ClickHouse documentation for more information.