Skip to content

Commit b12ff25

Browse files
committed
fix(v3): Apply suggestion from code review to combine query-system-data with system-tables.md. Fix prepare-content delimiter.
1 parent aec2ea0 commit b12ff25

File tree

5 files changed

+167
-177
lines changed

5 files changed

+167
-177
lines changed

content/influxdb/cloud-dedicated/admin/query-system-data.md

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ menu:
1010
weight: 105
1111
related:
1212
- /influxdb/cloud-dedicated/reference/cli/influxctl/query/
13+
- /influxdb/cloud-dedicated/reference/internals/system-tables/
1314
---
1415

1516
{{< product-name >}} stores data related to queries, tables, partitions, and
1617
compaction in _system tables_ within your cluster.
18+
System tables contain time series data used by and generated from the
19+
{{< product-name >}} internal monitoring system.
1720
You can query the cluster system tables for information about your cluster.
1821

1922
- [Query system tables](#query-system-tables)
2023
- [Optimize queries to reduce impact to your cluster](#optimize-queries-to-reduce-impact-to-your-cluster)
2124
- [System tables](#system-tables)
25+
- [Understanding system table data distribution](#understanding-system-table-data-distribution)
2226
- [system.queries](#systemqueries)
2327
- [system.tables](#systemtables)
2428
- [system.partitions](#systempartitions)
@@ -50,7 +54,6 @@ If you detect a schema change or a non-functioning query example, please
5054

5155
## Query system tables
5256

53-
5457
{{% note %}}
5558
Querying system tables with `influxctl` requires **`influxctl` v2.8.0 or newer**.
5659
{{% /note %}}
@@ -259,19 +262,40 @@ Use the `AND`, `OR`, or `IN` keywords to combine filters in your query.
259262
_System tables are [subject to change](#system-tables-are-subject-to-change)._
260263
{{% /warn %}}
261264

265+
### Understanding system table data distribution
266+
267+
Data in `system.tables`, `system.partitions`, and `system.compactor` includes
268+
data for all [InfluxDB Queriers](/influxdb/cloud-dedicated/reference/internals/storage-engine/#querier) in your cluster.
269+
The data comes from the catalog, and because all the queriers share one catalog,
270+
the results from these three tables derive from the same source data,
271+
regardless of which querier you connect to.
272+
273+
However, the `system.queries` table is different--data is local to each Querier.
274+
`system.queries` contains a non-persisted log of queries run against the current
275+
querier to which your query is routed.
276+
The query log is specific to the current Querier and isn't shared across
277+
queriers in your cluster.
278+
Logs are scoped to the specified database.
279+
262280
- [system.queries](#systemqueries)
263281
- [system.tables](#systemtables)
264282
- [system.partitions](#systempartitions)
265283
- [system.compactor](#systemcompactor)
266284

267285
### system.queries
268286

269-
The `system.queries` table contains an unpersisted log of queries run against
270-
the current [InfluxDB Querier](/influxdb/cloud-dedicated/reference/internals/storage-engine/#querier)
271-
to which your query is routed.
272-
The query log is specific to the current Querier and is not shared across Queriers
273-
in your cluster.
274-
Logs are scoped to the specified database.
287+
The `system.queries` table stores log entries for queries executed for the provided namespace (database) on the node that is _currently handling queries_.
288+
`system.queries` reflects a process-local, in-memory, namespace-scoped query log.
289+
290+
While this table may be useful for debugging and monitoring queries, keep the following in mind:
291+
292+
- Records stored in `system.queries` are transient and volatile
293+
- InfluxDB deletes `system.queries` records during pod restarts.
294+
- Queries for one namespace can evict records from another namespace.
295+
- Data reflects the state of a specific pod answering queries for the namespace.
296+
- Data isn't shared across queriers in your cluster.
297+
- A query for records in `system.queries` can return different results
298+
depending on the pod the request was routed to.
275299

276300
{{< expand-wrapper >}}
277301
{{% expand "View `system.queries` schema" %}}
@@ -280,9 +304,9 @@ The `system.queries` table contains the following columns:
280304

281305
- id
282306
- phase
283-
- issue_time
284-
- query_type
285-
- query_text
307+
- **issue_time**: timestamp when the query was issued
308+
- **query_type**: type (syntax: `sql`, `flightsql`, or `influxql`) of the query
309+
- **query_text**: query statement text
286310
- partitions
287311
- parquet_files
288312
- plan_duration
@@ -291,14 +315,20 @@ The `system.queries` table contains the following columns:
291315
- end2end_duration
292316
- compute_duration
293317
- max_memory
294-
- success
318+
- **success**: execution status (boolean) of the query
295319
- running
296320
- cancelled
297-
- trace_id
321+
- **trace_id**: trace ID for debugging and monitoring events
298322

299323
{{% /expand %}}
300324
{{< /expand-wrapper >}}
301325

326+
{{% note %}}
327+
_When listing measurements (tables) available within a namespace,
328+
some clients and query tools may include the `queries` table in the list of
329+
namespace tables._
330+
{{% /note %}}
331+
302332
### system.tables
303333

304334
The `system.tables` table contains information about tables in the specified database.
@@ -372,6 +402,7 @@ The examples in this section include `WHERE` filters to [optimize queries and re
372402
- [Query logs](#query-logs)
373403
- [View all stored query logs](#view-all-stored-query-logs)
374404
- [View query logs for queries with end-to-end durations above a threshold](#view-query-logs-for-queries-with-end-to-end-durations-above-a-threshold)
405+
- [View query logs for a specific query within a time interval](#view-query-logs-for-a-specific-query-within-a-time-interval)
375406
- [Partitions](#partitions)
376407
- [View the partition template of a specific table](#view-the-partition-template-of-a-specific-table)
377408
- [View all partitions for a table](#view-all-partitions-for-a-table)
@@ -414,6 +445,46 @@ WHERE
414445
end2end_duration::BIGINT > (50 * 1000000)
415446
```
416447

448+
### View query logs for a specific query within a time interval
449+
450+
{{< code-tabs >}}
451+
{{% tabs %}}
452+
[SQL](#)
453+
[Python](#)
454+
{{% /tabs %}}
455+
{{% code-tab-content %}}
456+
<!-----------------------------------BEGIN SQL------------------------------>
457+
```sql
458+
SELECT *
459+
FROM system.queries
460+
WHERE issue_time >= now() - INTERVAL '1 day'
461+
AND query_text LIKE '%select * from home%'
462+
```
463+
<!-----------------------------------END SQL------------------------------>
464+
{{% /code-tab-content %}}
465+
{{% code-tab-content %}}
466+
<!-----------------------------------BEGIN PYTHON------------------------------>
467+
```python
468+
from influxdb_client_3 import InfluxDBClient3
469+
client = InfluxDBClient3(token = DATABASE_TOKEN,
470+
host = HOSTNAME,
471+
org = '',
472+
database=DATABASE_NAME)
473+
client.query('select * from home')
474+
reader = client.query('''
475+
SELECT *
476+
FROM system.queries
477+
WHERE issue_time >= now() - INTERVAL '1 day'
478+
AND query_text LIKE '%select * from home%'
479+
''',
480+
language='sql',
481+
headers=[(b"iox-debug", b"true")],
482+
mode="reader")
483+
```
484+
<!-----------------------------------END PYTHON------------------------------>
485+
{{% /code-tab-content %}}
486+
{{< /code-tabs >}}
487+
417488
---
418489

419490
### Partitions

content/influxdb/cloud-dedicated/reference/internals/system-tables.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)