DDSQL
Execute a tabular DDSQL query
Submit a DDSQL statement and return either a running state with an opaque query_id for the client to poll, or a completed state with the column-major result set inlined when the query finishes quickly enough to be served synchronously.
For a scoped application key, include timeseries_query in its scopes. A query that does not read a data source, such as SELECT 1, requires no additional data-source permissions. Queries that read data sources also require the user or service account that owns the application key to have the corresponding data access permissions through their roles. The timeseries_query permission does not grant access to the underlying data sources.
post/api/v2/ddsql/query/tabular
Request
- Base URLhttps://api.datadoghq.com
- Auth
- API key in header DD-API-KEY and API key in header DD-APPLICATION-KEY
- or OAuth 2Authorization code/oauth2/v1/authorizeToken URL/oauth2/v1/tokenScopestimeseries_query
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"data": {
"attributes": {
"query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
"row_limit": 1000,
"time": {
"from_timestamp": 1736942400000,
"to_timestamp": 1736946000000
}
},
"type": "ddsql_query_request"
}
}Response
OK
Example response
{
"data": {
"attributes": {
"columns": [
{
"name": "service",
"type": "VARCHAR",
"values": [
"web-store",
"checkout"
]
}
],
"query_id": "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==",
"state": "completed",
"warnings": [
"Query result was truncated at the configured row_limit."
]
},
"id": "00000000-0000-0000-0000-000000000000",
"type": "ddsql_query_response"
},
"meta": {
"elapsed": 87,
"request_id": "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7082"
}
}Changes
Changes to this operation have not been checked yet.