Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pauldix
Copy link
Member

@pauldix pauldix commented Jan 20, 2025

To be merged after #5791

Copy link
Contributor

@jstirnaman jstirnaman left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> [!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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants