Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ BasedOnStyles = Vale, proselint
proselint.DateSpacing = NO
proselint.DateMidnight = NO
proselint.Needless = NO
proselint.Hyperbole = NO
proselint.CurlyQuotes = NO
50 changes: 50 additions & 0 deletions docs/api/api-convert-sql-to-tql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Converting SQL to TQL
tags: Advanced
description: Using the TelemetryDeck API, you can convert an SQL query to a TQL query
---

??? warning "Paid plans only"

API access — including running queries — is available on TelemetryDeck's paid plans. If your organization is on the free plan, upgrade your plan first and you'll be able to generate a personal access token and run queries.

??? note "Authorization"

You need a personal access token to authenticate against the TelemetryDeck API. Our article [Getting a Personal Access Token](api-token.md) explains how to generate one from your dashboard.

Sometimes you start with an SQL query, but want to later convert it to TQL to have a more structured query you can fine-tune.

## Running the query

POST your query to the `/api/v4/query/sql/convert` endpoint. The endpoint accepts SQL and returns an equivalent TQL query.

=== "Request"

```json
POST /api/v4/query/sql/convert HTTP/1.1
Authorization: Bearer tdpat_…
Content-Type: application/json
Host: api.telemetrydeckapi.com

{
"query": "SELECT \"type\", SUM(\"count\") AS events FROM {{events}} GROUP BY 1 ORDER BY 2 DESC LIMIT 10"
}
```

=== "Response"

```json
{
"aggregations": [{ "fieldName": "count", "name": "a0", "type": "longSum" }],
"dimension": {
"dimension": "type",
"outputName": "d0",
"outputType": "STRING",
"type": "default"
},
"granularity": { "type": "all" },
"metric": { "metric": "a0", "type": "numeric" },
"queryType": "topN",
"threshold": 10
}
```
53 changes: 53 additions & 0 deletions docs/api/api-run-query-sql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Running SQL Queries
tags: Advanced
description: Using the TelemetryDeck API, you can run an SQL query and retrieve its results
---

??? warning "Paid plans only"

API access — including running queries — is available on TelemetryDeck's paid plans. If your organization is on the free plan, upgrade your plan first and you'll be able to generate a personal access token and run queries.

??? note "Authorization"

You need a personal access token to authenticate against the TelemetryDeck API. Our article [Getting a Personal Access Token](api-token.md) explains how to generate one from your dashboard.

## Running the query

POST your query to the `/api/v4/query/sql` endpoint. The endpoint runs the query and returns the results in the same response. Please allow up to 2 minutes query execution time for complex requests.

=== "Request"

```json
POST /api/v4/query/sql HTTP/1.1
Authorization: Bearer tdpat_…
Content-Type: application/json
Host: api.telemetrydeckapi.com

{
"query": "SELECT \"type\", SUM(\"count\") AS events FROM \"com.example\" WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '\''7'\'' DAY GROUP BY 1 ORDER BY 2 DESC LIMIT 10",
"context": {}
}
```

=== "Response"

```json
[
["type", "events"],
["STRING", "LONG"],
["VARCHAR", "BIGINT"],
["TelemetryDeck.Navigation.pathChanged", 158207],
["TelemetryDeck.AuditLog.httpRequest", 27962],
["pageview", 17714],
["TelemetryDeck.Web.pageLeave", 7348],
["plans.view", 918],
["signupCaptchaSuccess", 584],
["organizationCreated", 530],
["appCreated", 505],
["signupCompleted", 418],
["conversionAction", 126]
]
```

The response body's exact shape depends on the query type.
15 changes: 6 additions & 9 deletions docs/api/api-run-query.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
---
title: Run Query
title: Running TQL Queries
tags: Advanced
testedOn: Query API v4
description: Using the TelemetryDeck API, you can run a query and retrieve its results
lead: Using the TelemetryDeck API, you can run a query and retrieve its results
order: 2
description: Using the TelemetryDeck API, you can run a TQL query and retrieve its results
---

!!! warning "Paid plans only"
??? warning "Paid plans only"

API access — including running queries — is available on TelemetryDeck's paid plans. If your organization is on the free plan, upgrade your plan first and you'll be able to generate a personal access token and run queries.

## Authorization
??? note "Authorization"

You need a personal access token to authenticate against the TelemetryDeck API. Our article [Getting a Personal Access Token](api-token.md) explains how to generate one from your dashboard.
You need a personal access token to authenticate against the TelemetryDeck API. Our article [Getting a Personal Access Token](api-token.md) explains how to generate one from your dashboard.

## TelemetryDeck Query Language

TelemetryDeck Query Language (TQL) is a JSON-based language for querying time-series data stored in TelemetryDeck. You can either write a query by hand, or [generate a query from an insight](api-query-from-insight.md).

## Running the query

POST your query to the `/api/v4/query/tql` endpoint. The endpoint runs the query and returns the results in the same response. Please allow up to 2 minutes query execution time for very complicated requests.
POST your query to the `/api/v4/query/tql` endpoint. The endpoint runs the query and returns the results in the same response. Please allow up to 2 minutes query execution time for complex requests.

Request:

Expand Down
1 change: 0 additions & 1 deletion docs/api/api.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/articles/articles.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/basics/basics.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/ingest/ingest.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/integrations/integrations.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/tql/recipes/recipes.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/tql/tql.json

This file was deleted.

Loading
Loading