Skip to content

Commit 7ce4497

Browse files
committed
feat(mono): Query system data: convert the example query to an API request
1 parent faa6901 commit 7ce4497

File tree

1 file changed

+29
-7
lines changed
  • content/shared/influxdb3-admin/query-system-data

1 file changed

+29
-7
lines changed

content/shared/influxdb3-admin/query-system-data/_index.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ You can query the system tables for information about your running server, datab
55
## Query system tables
66

77
- [Use the HTTP query API](#use-the-http-query-api)
8-
- [Example: show tables](#example-show-tables)
9-
- [Example: view column information for a table](#example-view-column-information-for-a-table)
8+
- [Examples](#examples)
9+
- [Show tables](#show-tables)
10+
- [View column information for a table](#view-column-information-for-a-table)
1011

1112
### Use the HTTP query API
1213

@@ -32,7 +33,18 @@ Include the following parameters:
3233
JSONL (`jsonl`) is preferred because it streams results back to the client.
3334
`pretty` is for human-readable output. Default is `json`.
3435

35-
#### Example: show tables
36+
#### Examples
37+
38+
> [!Note]
39+
> #### system_ sample data
40+
>
41+
> In examples, tables with `"table_name":"system_` are user-created tables for CPU, memory, disk,
42+
> network, and other resource statistics collected and written
43+
> by the user--for example, using the `psutil` Python library or
44+
> [Telegraf](https://docs.influxdata.com/telegraf/v1/get-started/) to collect
45+
> and write system metrics to an InfluxDB 3 database.
46+
47+
##### Show tables
3648

3749
The following example sends a `GET` request that executes a `show tables` query
3850
to retrieve all user-created
@@ -76,7 +88,7 @@ A table has one of the following `table_schema` values:
7688
while others, such as the `queries` table, hold ephemeral state in memory.
7789
- `information_schema`: views that show schema information for tables in the database.
7890

79-
#### Example: view column information for a table
91+
#### View column information for a table
8092

8193
The following query sends a `POST` request that executes an SQL query to
8294
retrieve information about columns in the sample `system_swap` table schema:
@@ -88,7 +100,7 @@ that surround field names._
88100
curl "http://localhost:8181/api/v3/query_sql" \
89101
--header "Content-Type: application/json" \
90102
--json '{
91-
"db": "cpu",
103+
"db": "mydb",
92104
"q": "SELECT * FROM information_schema.columns WHERE table_schema = '"'iox'"' AND table_name = '"'system_swap'"'",
93105
"format": "jsonl"
94106
}'
@@ -107,12 +119,22 @@ The output is the following:
107119
{"table_catalog":"public","table_schema":"iox","table_name":"system_swap","column_name":"used","ordinal_position":7,"is_nullable":"YES","data_type":"UInt64"}
108120
```
109121

122+
#### Recently executed queries
123+
110124
To view recently executed queries, query the `queries` system table:
111125

112-
```SQL
113-
SELECT * FROM system.queries LIMIT 2
126+
```bash
127+
curl "http://localhost:8181/api/v3/query_sql" \
128+
--header "Content-Type: application/json" \
129+
--json '{
130+
"db": "mydb",
131+
"q": "SELECT * FROM system.queries LIMIT 2",
132+
"format": "jsonl"
133+
}'
114134
```
115135

136+
The output is the following:
137+
116138
```jsonl
117139
{"id":"cdd63409-1822-4e65-8e3a-d274d553dbb3","phase":"success","issue_time":"2025-01-20T17:01:40.690067","query_type":"sql","query_text":"show tables","partitions":0,"parquet_files":0,"plan_duration":"PT0.032689S","permit_duration":"PT0.000202S","execute_duration":"PT0.000223S","end2end_duration":"PT0.033115S","compute_duration":"P0D","max_memory":0,"success":true,"running":false,"cancelled":false}
118140
{"id":"47f8d312-5e75-4db2-837a-6fcf94c09927","phase":"success","issue_time":"2025-01-20T17:02:32.627782","query_type":"sql","query_text":"show tables","partitions":0,"parquet_files":0,"plan_duration":"PT0.000583S","permit_duration":"PT0.000015S","execute_duration":"PT0.000063S","end2end_duration":"PT0.000662S","compute_duration":"P0D","max_memory":0,"success":true,"running":false,"cancelled":false}

0 commit comments

Comments
 (0)