Skip to content

Commit

Permalink
Add InfluxDB 3 query guides (#5798)
Browse files Browse the repository at this point in the history
* base content for influxdb3 query guides

* added enterprise versions of query guides

* Apply suggestions from code review

Co-authored-by: Jason Stirnaman <[email protected]>

* update template titles to use .RenderString

---------

Co-authored-by: Jason Stirnaman <[email protected]>
  • Loading branch information
sanderson and jstirnaman authored Jan 23, 2025
1 parent 824b2f8 commit 86bee7c
Show file tree
Hide file tree
Showing 84 changed files with 4,564 additions and 97 deletions.
2 changes: 1 addition & 1 deletion assets/js/custom-timestamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function updateTimestamps (newStartDate) {
oldDatePart = datePart(x.rfc3339.replace(/T.*$/, ''));
newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, ''));
rfc3339Regex = new RegExp(
`${oldDatePart.year}(.*)${oldDatePart.month}(.*)${oldDatePart.day}`,
`${oldDatePart.year}(.*?)${oldDatePart.month}(.*?)${oldDatePart.day}`,
'g'
);
rfc3339Repl = `${newDatePart.year}$1${newDatePart.month}$2${newDatePart.day}`;
Expand Down
4 changes: 4 additions & 0 deletions assets/styles/layouts/article/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ a.btn {
margin-right: -.65rem;
}

&.small {
padding: .4rem 1rem;
}

&.small-plus {
padding: .25em;
line-height: .65rem;
Expand Down
15 changes: 15 additions & 0 deletions content/influxdb3/core/query-data/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Query data in {{< product-name >}}
description: >
Learn to query data stored in InfluxDB using SQL and InfluxQL.
menu:
influxdb3_core:
name: Query data
weight: 4
influxdb3/core/tags: [query]
source: /shared/influxdb3-query-guides/_index.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/_index.md
-->
20 changes: 20 additions & 0 deletions content/influxdb3/core/query-data/execute-queries/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Execute queries
description: >
Use tools and libraries to query data stored in {{< product-name >}}.
weight: 101
menu:
influxdb3_core:
name: Execute queries
parent: Query data
influxdb3/core/tags: [query, sql, influxql]
aliases:
- /influxdb3/core/query-data/tools/
- /influxdb3/core/query-data/sql/execute-queries/
- /influxdb3/core/query-data/influxql/execute-queries/
source: /shared/influxdb3-query-guides/execute-queries/_index.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/execute-queries/_index.md
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Use the InfluxDB v1 HTTP query API and InfluxQL to query data
seotitle: Use InfluxQL and InfluxDB v1 HTTP query API
list_title: Use the v1 query API and InfluxQL
description: >
Use the InfluxDB v1 HTTP query API to query data in {{< product-name >}}
with InfluxQL.
weight: 302
menu:
influxdb3_core:
parent: Execute queries
name: Use the v1 query API
influxdb3/core/tags: [query, influxql, python]
metadata: [InfluxQL]
related:
- /influxdb3/core/api-compatibility/v1/
aliases:
- /influxdb3/core/query-data/influxql/execute-queries/influxdb-v1-api/
list_code_example: |
```sh
curl --get http://{{< influxdb/host >}}/query \
--header "Authorization: Token DATABASE_TOKEN" \
--data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=SELECT * FROM home"
```
source: /shared/influxdb3-query-guides/execute-queries/influxdb-v1-api.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/execute-queries/influxdb-v1-api.md
-->
28 changes: 28 additions & 0 deletions content/influxdb3/core/query-data/execute-queries/influxdb3-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Use the influxdb3 CLI to query data
list_title: Use the influxdb3 CLI
description: >
Use the `influxdb3 query` command to query data in {{< product-name >}} with SQL.
weight: 301
menu:
influxdb3_core:
parent: Execute queries
name: Use the influxdb3 CLI
influxdb3/core/tags: [query, sql, influxql, influxdb3, CLI]
related:
- /influxdb3/core/reference/cli/influxdb3/query/
- /influxdb3/core/reference/sql/
- /influxdb3/core/reference/influxql/
# - /influxdb3/core/get-started/query/#execute-an-sql-query, Get started querying data
list_code_example: |
```sh
influxdb3 query \
--database DATABASE_NAME \
"SELECT * FROM home"
```
source: /shared/influxdb3-query-guides/execute-queries/influxdb3-cli.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/execute-queries/influxdb3-cli.md
-->
16 changes: 16 additions & 0 deletions content/influxdb3/core/query-data/influxql/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Query data with InfluxQL
description: >
Learn to use InfluxQL to query data stored in {{< product-name >}}.
menu:
influxdb3_core:
name: Query with InfluxQL
parent: Query data
weight: 102
influxdb3/core/tags: [query, influxql]
source: /shared/influxdb3-query-guides/influxql/_index.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/_index.md
-->
41 changes: 41 additions & 0 deletions content/influxdb3/core/query-data/influxql/aggregate-select.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Aggregate data with InfluxQL
seotitle: Aggregate or apply selector functions to data with InfluxQL
description: >
Use InfluxQL aggregate and selector functions to perform aggregate operations
on your time series data.
menu:
influxdb3_core:
name: Aggregate data
parent: Query with InfluxQL
identifier: query-influxql-aggregate
weight: 203
influxdb3/core/tags: [query, influxql]
related:
- /influxdb3/core/reference/influxql/functions/aggregates/
- /influxdb3/core/reference/influxql/functions/selectors/
list_code_example: |
##### Aggregate fields by groups
```sql
SELECT
MEAN(temp) AS mean,
FIRST(hum) as first,
FROM home
GROUP BY tag
```
##### Aggregate by time-based intervals
```sql
SELECT
MEAN(temp),
sum(hum),
FROM home
WHERE time >= now() - 24h
GROUP BY time(1h),room
```
source: /shared/influxdb3-query-guides/influxql/aggregate-select.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/aggregate-select.md
-->
23 changes: 23 additions & 0 deletions content/influxdb3/core/query-data/influxql/basic-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Perform a basic InfluxQL query
seotitle: Perform a basic InfluxQL query in {{< product-name >}}
description: >
A basic InfluxQL query that queries data from InfluxDB most commonly includes
`SELECT`, `FROM`, and `WHERE` clauses.
menu:
influxdb3_core:
name: Basic query
parent: Query with InfluxQL
identifier: query-influxql-basic
weight: 202
influxdb3/core/tags: [query, influxql]
list_code_example: |
```sql
SELECT temp, room FROM home WHERE time >= now() - 1d
```
source: /shared/influxdb3-query-guides/influxql/basic-query.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/basic-query.md
-->
39 changes: 39 additions & 0 deletions content/influxdb3/core/query-data/influxql/explore-schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Explore your schema with InfluxQL
description: >
Use InfluxQL `SHOW` statements to return information about your data schema.
menu:
influxdb3_core:
name: Explore your schema
parent: Query with InfluxQL
identifier: query-influxql-schema
weight: 201
influxdb3/core/tags: [query, influxql]
related:
- /influxdb3/core/reference/influxql/show/
list_code_example: |
##### List measurements
```sql
SHOW MEASUREMENTS
```
##### List field keys in a measurement
```sql
SHOW FIELD KEYS FROM "measurement"
```
##### List tag keys in a measurement
```sql
SHOW TAG KEYS FROM "measurement"
```
##### List tag values for a specific tag key
```sql
SHOW TAG VALUES FROM "measurement" WITH KEY = "tag-key" WHERE time > now() - 1d
```
source: /shared/influxdb3-query-guides/influxql/explore-schema.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/explore-schema.md
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Use parameterized queries with InfluxQL
description: >
Use parameterized queries to prevent injection attacks and make queries more reusable.
weight: 404
menu:
influxdb3_core:
name: Parameterized queries
parent: Query with InfluxQL
identifier: parameterized-queries-influxql
influxdb3/core/tags: [query, security, influxql]
list_code_example: |
##### Using Go and the influxdb3-go client
```go
// Use the $parameter syntax to reference parameters in a query.
// The following InfluxQL query contains $room and $min_time parameters.
query := `
SELECT * FROM home
WHERE time >= $min_time
AND temp >= $min_temp
AND room = $room`
// Assign parameter names to input values.
parameters := influxdb3.QueryParameters{
"room": "Kitchen",
"min_temp": 20.0,
"min_time": "2024-03-18 00:00:00.00",
}
// Call the client's function to query InfluxDB with parameters and the
// the InfluxQL QueryType.
iterator, err := client.QueryWithParameters(context.Background(),
query,
parameters,
influxdb3.WithQueryType(influxdb3.InfluxQL))
```
# Leaving in draft until tested
draft: true
source: /shared/influxdb3-query-guides/influxql/parameterized-queries.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/parameterized-queries.md
-->
15 changes: 15 additions & 0 deletions content/influxdb3/core/query-data/influxql/troubleshoot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Troubleshoot InfluxQL errors
description: >
Learn how to troubleshoot and fix common InfluxQL errors.
menu:
influxdb3_core:
name: Troubleshoot errors
parent: Query with InfluxQL
weight: 230
source: /shared/influxdb3-query-guides/influxql/troubleshoot.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/influxql/troubleshoot.md
-->
17 changes: 17 additions & 0 deletions content/influxdb3/core/query-data/sql/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Query data with SQL
seotitle: Query data with SQL
description: >
Learn to query data stored in {{< product-name >}} using SQL.
menu:
influxdb3_core:
name: Query with SQL
parent: Query data
weight: 101
influxdb3/core/tags: [query, sql]
source: /shared/influxdb3-query-guides/sql/_index.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/sql/_index.md
-->
43 changes: 43 additions & 0 deletions content/influxdb3/core/query-data/sql/aggregate-select.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Aggregate data with SQL
description: >
Use aggregate and selector functions to perform aggregate operations on your
time series data.
menu:
influxdb3_core:
name: Aggregate data
parent: Query with SQL
identifier: query-sql-aggregate
weight: 203
influxdb3/core/tags: [query, sql]
related:
- /influxdb3/core/reference/sql/functions/aggregate/
- /influxdb3/core/reference/sql/functions/selector/
- /influxdb3/core/reference/sql/group-by/
list_code_example: |
##### Aggregate fields by groups
```sql
SELECT
mean(field1) AS mean,
selector_first(field2)['value'] as first,
tag1
FROM home
GROUP BY tag
```
##### Aggregate by time-based intervals
```sql
SELECT
DATE_BIN(INTERVAL '1 hour', time, '2022-01-01T00:00:00Z'::TIMESTAMP) AS time,
mean(field1),
sum(field2),
tag1
FROM home
GROUP BY 1, tag1
```
source: /shared/influxdb3-query-guides/sql/aggregate-select.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/sql/aggregate-select.md
-->
23 changes: 23 additions & 0 deletions content/influxdb3/core/query-data/sql/basic-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Perform a basic SQL query
seotitle: Perform a basic SQL query in InfluxDB 3 Core
description: >
A basic SQL query that queries data from {{< product-name >}} most commonly
includes `SELECT`, `FROM`, and `WHERE` clauses.
menu:
influxdb3_core:
name: Basic query
parent: Query with SQL
identifier: query-sql-basic
weight: 202
influxdb3/core/tags: [query, sql]
list_code_example: |
```sql
SELECT temp, room FROM home WHERE time >= now() - INTERVAL '1 day'
```
source: /shared/influxdb3-query-guides/sql/basic-query.md
---

<!--
The content for this page is at content/shared/influxdb3-query-guides/sql/basic-query.md
-->
Loading

0 comments on commit 86bee7c

Please sign in to comment.