-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add page for HTTP Query API for Core and Enterprise #5792
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes and suggestions.
@@ -0,0 +1,79 @@ | |||
This guide shows some of the capabilities of the HTTP API API for querying and accessing useful information from system tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guide shows some of the capabilities of the HTTP API API for querying and accessing useful information from system tables. | |
Learn how to use the HTTP API to query and access information about the database server and table schemas. |
```shell | ||
curl "http://localhost:8181/api/v3/query_sql?db=mydb&format=jsonl&q=show%20tables" | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> [!Note] | |
> #### system_ sample data | |
> | |
> In this guide, tables with `"table_name":"system_` represent CPU, memory, disk, network, and other resource usage statistics written by the user to the database for storage and querying. | |
> For example, you can use [Telegraf](https://docs.influxdata.com/telegraf/v1/get-started/) to collect and write metrics from your system to an InfluxDB 3 database. |
- `params` - A JSON object containing parameters to be used in the query (for parameterize SQL) | ||
- `format` - The format of the response. Can be `json`, `jsonl`, `csv`, `pretty`, or `parquet`. JSONL is the preferred format as it will stream the results back to the client. Pretty is for human-readable output. | ||
|
||
For example, running the `show tables` query, which will show all user created tables (listed as `table_schema` of `iox`), system tables, and information schema tables. Here's the command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, running the `show tables` query, which will show all user created tables (listed as `table_schema` of `iox`), system tables, and information schema tables. Here's the command: | |
For example, run the `show tables` query to view all user-created tables (`"table_schema":"iox"`), system tables, and information schema tables: |
curl "http://localhost:8181/api/v3/query_sql?db=mydb&format=jsonl&q=show%20tables" | ||
``` | ||
|
||
Returns the following JSONL output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the following JSONL output | |
The response body contains the following JSONL: |
table | ||
|
||
```SQL | ||
SELECT * FROM information_schema.columns where table_schema = 'iox' AND table_name = 'system_cpu' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT * FROM information_schema.columns where table_schema = 'iox' AND table_name = 'system_cpu' | |
SELECT * FROM information_schema.columns where table_schema = 'iox' AND table_name = 'system_swap' |
``` | ||
|
||
### Schedule Trigger Configuration | ||
Schedule plugins are set with a `trigger-spec` of `schedule:<cron_expression>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run the check every minute, we would use `schedule:*/5 * * * *` as the `trigger-spec`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schedule plugins are set with a `trigger-spec` of `schedule:<cron_expression>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run the check every minute, we would use `schedule:*/5 * * * *` as the `trigger-spec`. | |
Schedule plugins are set with a `trigger-spec` of `schedule:<cron_expression>`. The `args` parameter can be used to pass configuration to the plugin. | |
For example, to run the plugin in the preceding example every minute, use `schedule:*/5 * * * *` as the `trigger-spec`. |
For the WAL plugin, the `trigger-spec` can be either `all-tables` which will trigger on any write to the assoicated database or `table:<table_name>` which will call the `process_writes` function only with the writes for the given table. The `args` parameter can be used to pass configuration to the plugin. | ||
|
||
## Schedule Plugin | ||
Schedule plugins run on a schedule specified in cron syntax. The plugin will receive the local API, the time of the trigger, and any arguments passed in the trigger definition. Here's an example of a simple schedule plugin: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schedule plugins run on a schedule specified in cron syntax. The plugin will receive the local API, the time of the trigger, and any arguments passed in the trigger definition. Here's an example of a simple schedule plugin: | |
Schedule plugins run on a schedule specified in cron syntax. The plugin receives the local API, the time of the trigger, and any arguments passed in the trigger definition. | |
The following example shows a simple schedule plugin: |
Schedule plugins are set with a `trigger-spec` of `schedule:<cron_expression>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run the check every minute, we would use `schedule:*/5 * * * *` as the `trigger-spec`. | ||
|
||
## On Request Plugin | ||
On Request plugins are triggered by a request to a specific endpoint under `/api/v3/engine`. The plugin will receive the local API, query parameters `Dict[str, str]`, request headers `Dict[str, str]`, request body (as bytes), and any arguments passed in the trigger definition. Here's an example of a simple On Request plugin: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Request plugins are triggered by a request to a specific endpoint under `/api/v3/engine`. The plugin will receive the local API, query parameters `Dict[str, str]`, request headers `Dict[str, str]`, request body (as bytes), and any arguments passed in the trigger definition. Here's an example of a simple On Request plugin: | |
On Request plugins are triggered by a request to a specific endpoint under `/api/v3/engine`. | |
The plugin receives the local API, query parameters `Dict[str, str]`, HTTP request headers `Dict[str, str]`, HTTP request body (as bytes), and any arguments passed in the trigger definition. | |
The following example shows a simple On Request plugin: |
``` | ||
|
||
### On Request Trigger Configuration | ||
On Request plugins are set with a `trigger-spec` of `request:<endpoint>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run on the endpoint `/api/v3/engine/my_plugin`, we would use `request:my_plugin` as the `trigger-spec`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Request plugins are set with a `trigger-spec` of `request:<endpoint>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run on the endpoint `/api/v3/engine/my_plugin`, we would use `request:my_plugin` as the `trigger-spec`. | |
When creating a trigger for an On Request plugin, set the `trigger-spec` to `request:<endpoint>. | |
For example, to create an HTTP API `/api/v3/engine/my_plugin` endpoint that runs the plugin in the preceding example, pass `request:my_plugin` as the `trigger-spec`. | |
You can use the `args` parameter to pass any additional configuration to the plugin. |
### On Request Trigger Configuration | ||
On Request plugins are set with a `trigger-spec` of `request:<endpoint>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run on the endpoint `/api/v3/engine/my_plugin`, we would use `request:my_plugin` as the `trigger-spec`. | ||
|
||
Trigger specs must be unique across all configured plugins, regardless of which database they are tied to, given the path is the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trigger specs must be unique across all configured plugins, regardless of which database they are tied to, given the path is the same. | |
Because all On Request triggers for a server use the same `/api/v3/engine` root path, trigger specs must be unique across all configured plugins, regardless of which database they are associated with. |
To be merged after #5791