Skip to content

Commit

Permalink
update cli usages/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
judell committed Jan 28, 2025
1 parent 566cc66 commit 884be29
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 50 deletions.
3 changes: 1 addition & 2 deletions docs/reference/cli/collect.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Run a **collection**.
|-|-
| `--compact` | Compact the Parquet files after collection (default true)
| `--from string` | Collect days newer than a relative or absolute date.
| `--output output` | Output format; one of: json, table (default text)
| `--help` | Help for connect
| `--help` | Help for collect

## Examples

Expand Down
9 changes: 2 additions & 7 deletions docs/reference/cli/compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Compact multiple Parquet files per day to one per day.

# tailpipe compact

>[!NOTE]
> Given that collect's --compact defaults to true, why would I use this?
# Usage
```bash
tailpipe compact [table] [table.partition] [args]
Expand All @@ -18,10 +15,8 @@ Compact multiple Parquet files per day to one per day.

| Flag | Description
|-|-
| `--from string` | Compact days newer than a relative or absolute date.
| `--to string` | Compact days older than a relative or absolute date.
| `--output output` | Output format; one of: json, table (default text)
| `--help` | Help for connect
| `--help` | Help for compact
| `--output` | Output format; one of: json, table (default text)

## Examples

Expand Down
16 changes: 14 additions & 2 deletions docs/reference/cli/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ Return a connection string for a database, with a schema determined by the provi
| Flag | Description
|-|-
| `--from string` | Specify the start time
| `--to string` | Specify the end time
| `--output output` | Output format; one of: json, table (default text)
| `--help` | Help for connect
| `--index strings` | Specify the index(es) to use
| `--output` | Output format; one of: json, table (default text)
| `--partition strings` | Specify the partition(s) to use
| `--to string` | Specify the end time

## Examples

Expand All @@ -34,6 +36,16 @@ tailpipe connect --from 2025-01-01
>
> duckdb /home/jon/.tailpipe/data/default/tailpipe_20241212134120.db
```bash
tailpipe connect --from 2025-01-01
/home/jon/.tailpipe/data/default/tailpipe_20250115140447.db
```

```bash
tailpipe connect --from 2025-01-01
/home/jon/.tailpipe/data/default/tailpipe_20250115140447.db
```

Show the filepath for the connected database:

```bash
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cli/partition.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ List, show, and delete Tailpipe partitions.

## Usage
```bash
tailpipe partition delete table_name.partition_name [args]
tailpipe partition list [args]
tailpipe partition show table_name.partition_name [args]
tailpipe partition delete table_name.partition_name [args]
```

## Sub-Commands

| Command | Description
|-|-
| [delete](#tailpipe-partition-delete) | Delete a partition.
| [list](#tailpipe-partition-list) | List all partitions.
| [show](#tailpipe-partition-show) | Show details of a partition.
| [delete](#tailpipe-partition-delete) | Delete a partition.


## tailpipe partition list
Expand Down
65 changes: 30 additions & 35 deletions docs/reference/cli/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ title: tailpipe query

# tailpipe query

>[!NOTE]
> Cloned from Steampipe with minor variation. I took out search_path and search_path_pefix. Should also remove timing? query-timeout?
Query a Tailpipe table

## Usage
Expand Down Expand Up @@ -36,22 +33,14 @@ tailpipe query {query} [flags]

| Argument | Description
|--|--
| `--export string` | Export query output to a file. You may export multiple output formats by entering multiple `--export` arguments. If a file path is specified as an argument, its type will be inferred by the suffix. Supported export formats are `sps` (`snapshot`).
| `--from string` | Specify the start time
| `--header string` | Specify whether to include column headers in csv and table output (default true`)|
| `--help` | Help for `tailpipe query`.
| `--output string` | Select the console output format. Possible values are `line, csv, json, table, snapshot` (default `table`).
| `--pipes-host` | Sets the Turbot Pipes host used when connecting to Turbot Pipes workspaces. See [PIPES_HOST](reference/env-vars/pipes_host) for details.
`--pipes-token` | Sets the Turbot Pipes authentication token used when connecting to Turbot Pipes workspaces. See [PIPES_TOKEN](reference/env-vars/pipes_token) for details.
| `--progress` | Enable or disable progress information. By default, progress information is shown - set `--progress=false` to hide the progress bar.
| `--query-timeout int` | The query timeout, in seconds. The default is `0` (no timeout).
| `--share` | Create snapshot in Turbot Pipes with `anyone_with_link` visibility.
| `--snapshot` | Create snapshot in Turbot Pipes with the default (`workspace`) visibility.
| `--snapshot-location string` | The location to write snapshots - either a local file path or a Turbot Pipes workspace.
| `--snapshot-tag string=string` | Specify tags to set on the snapshot. Multiple `--snapshot-tag` arguments may be passed.
| `--snapshot-title string` | The title to give a snapshot when uploading to Turbot Pipes.
| `--timing=string` | Enable or disable query execution timing: `off` (default), `on`, or `verbose`.
| `--workspace-database` | Sets the database that Tailpipe will connect to. This can be `local` (the default) or a remote Turbot Pipes database. See [STEAMPIPE_WORKSPACE_DATABASE](/docs/reference/env-vars/steampipe_workspace_database) for details.

| `--help` | Help for `tailpipe query`
| `--index strings` | Specify the index(es) to use
| `--output output | Output format; one of: table, csv, json, line (default table)
| `--partition strings` | Specify the partition(s) to use
| `--separator string` | Separator string for csv output (default ",")
| `--to string` | Specify the end time


## Examples
Expand All @@ -63,52 +52,58 @@ tailpipe query

Run a specific query directly:
```bash
tailpipe query "select * from aws_cloudtrail_log"
tailpipe query "select count(*) from aws_cloudtrail_log"
```

Run a query and save a [snapshot](/docs/snapshots/batch-snapshots):
Query from a date:
```bash
tailpipe query --snapshot "select * from aws_cloudtrail_log"
tailpipe query "select count(*) from aws_cloudtrail_log" --from 2025-01-01
```

Run a query and share a [snapshot](/docs/snapshots/batch-snapshots):
Query within a range of dates:
```bash
tailpipe query --share "select * from aws_cloudtrail_log"
tailpipe query "select count(*) from aws_cloudtrail_log" --from 2025-01-01 --to 2025-01-31
```

Run the SQL command in the `my_queries/my_query.sql` file:
Query a specific partition:
```bash
tailpipe query my_queries/my_query.sql
tailpipe query "select count(*) from aws_cloudtrail_log --partition flaws
```
Query two partitions:
```bash
tailpipe query "select count(*) from aws_cloudtrail_log --partition flaws,prod
```

Run the SQL commands in all `.sql` files in the `my_queries` directory and concatenate the results:
Query a specific index:
```bash
tailpipe query my_queries/*.sql
tailpipe query "select count(*) from aws_cloudtrail_log --index 605491513981
```
Run a query and report the query execution time:
Run a query and save a [snapshot](/docs/snapshots/batch-snapshots):
```bash
tailpipe query "select * from aws_cloudtrail_log" --timing
tailpipe query --snapshot "select * from aws_cloudtrail_log"
```
Run a query and report the query execution time and details for each scan:
Run a query and share a [snapshot](/docs/snapshots/batch-snapshots):
```bash
tailpipe query "select * from aws_cloudtrail_log" --timing=verbose
tailpipe query --share "select * from aws_cloudtrail_log"
```
Run a query and return output in json format:
Run the SQL command in the `my_queries/my_query.sql` file:
```bash
tailpipe query "select * from aws_cloudtrail_log" --output json
tailpipe query my_queries/my_query.sql
```
```
Run a query and return output in CSV format:
```bash
tailpipe query "select * from aws_cloudtrail_log" --output csv
tailpipe query "select * from aws_cloudtrail_log limit 1000" --output csv
```
Run a query and return output in pipe-separated format:
```bash
tailpipe query "select * from aws_cloudtrail_log" --output csv --separator '|'
tailpipe query "select * from aws_cloudtrail_log limit 1000" --output csv --separator '|'
```
4 changes: 2 additions & 2 deletions docs/reference/cli/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Show details for a table.
Show details in table format.

```bash
tailpipe table show github_audit_log.prod
tailpipe table show pipes_audit_log.prod
```

Show details in JSON format.

```bash
tailpipe table show github_audit_log.prod --output json
tailpipe table show pipes_audit_log.prod --output json
```

0 comments on commit 884be29

Please sign in to comment.