Follow redirects
Make sure to follow redirects when using this API.
For example, use the -L
option with curl
.
Run Dashboard metric queries with an HTTP API.
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.
Inspect metrics with a SQL query. Use the same SQL you would use in Dashboards. Read more about Dashboard SQL queries.
Start of time range for the SQL 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 SQL query (ISO8601-formatted string: 2022-07-19T13:32:56+0000). Default: 30 minutes after from
. If from
is not specified then current time.
Headers
Bearer $TOKEN
Returned rows in JSONEachRow format
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!"}
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
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.