@hyperdx/cli 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -22
- package/dist/cli.js +3698 -2298
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,12 +1,223 @@
|
|
|
1
1
|
# @hyperdx/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@hyperdx/cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Terminal UI and CLI for [HyperDX](https://github.com/hyperdxio/hyperdx) —
|
|
7
|
+
search, tail, chart, and query your logs, traces, and metrics without leaving
|
|
8
|
+
the terminal.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
The CLI talks to your HyperDX instance (Cloud or self-hosted) and runs the exact
|
|
11
|
+
same query pipeline as the web app, so results always match what you see in the
|
|
12
|
+
browser.
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @hyperdx/cli # installs the `hdx` binary
|
|
18
|
+
# or run without installing:
|
|
19
|
+
npx @hyperdx/cli --help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires Node.js >= 22.16.
|
|
23
|
+
|
|
24
|
+
## Quickstart
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Sign in (interactive — prompts for app URL and credentials)
|
|
28
|
+
hdx auth login
|
|
29
|
+
|
|
30
|
+
# Launch the interactive TUI
|
|
31
|
+
hdx tui
|
|
32
|
+
|
|
33
|
+
# Chart error volume by service for the past 3 hours
|
|
34
|
+
hdx chart -s Logs --where 'SeverityText:error' --group-by ServiceName --since 3h
|
|
35
|
+
|
|
36
|
+
# Run raw SQL against ClickHouse
|
|
37
|
+
hdx query --connection-id "$CONN" --sql "SELECT count() FROM default.otel_logs"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Interactive TUI** — search and live-tail events, inspect rows, and walk
|
|
43
|
+
trace waterfalls with vim-style keybindings
|
|
44
|
+
- **Trace waterfall** — full span tree with correlated logs, span-level detail,
|
|
45
|
+
and open-in-browser deep links
|
|
46
|
+
- **Terminal charts** — render saved dashboard tiles or ad-hoc charts (line,
|
|
47
|
+
stacked bar, number, table, bar, pie) as ANSI output
|
|
48
|
+
- **Raw SQL** — query ClickHouse directly through the HyperDX proxy, in any
|
|
49
|
+
ClickHouse output format
|
|
50
|
+
- **Log pattern mining** — cluster query results into Drain log patterns to
|
|
51
|
+
summarize large result sets
|
|
52
|
+
- **Alerts & dashboards** — browse alerts (with trigger history) and dashboards
|
|
53
|
+
from the TUI
|
|
54
|
+
- **Multi-team support** — kubectx-style team switching for users in multiple
|
|
55
|
+
teams
|
|
56
|
+
- **Agent-friendly** — `--json` output on discovery commands, NDJSON streaming,
|
|
57
|
+
documented exit codes, and colors stripped automatically when piping
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
hdx tui # Interactive TUI (search + live tail)
|
|
63
|
+
hdx chart -d <dashboard> [-t tile] # Render dashboard tiles as ANSI charts
|
|
64
|
+
hdx chart -s <source> [--agg ...] # Ad-hoc chart over a source
|
|
65
|
+
hdx chart --sql <query> -s <source> # Ad-hoc chart from raw SQL
|
|
66
|
+
hdx query --connection-id <id> --sql <query> # Raw SQL to stdout
|
|
67
|
+
hdx sources # List data sources with table schemas
|
|
68
|
+
hdx connections # List ClickHouse connections
|
|
69
|
+
hdx dashboards # List dashboards with tile summaries
|
|
70
|
+
hdx auth login|status|logout # Manage authentication
|
|
71
|
+
hdx team list|current|use <team> # Switch between teams
|
|
72
|
+
hdx upload-sourcemaps # Upload JS source maps
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Every command accepts `-a, --app-url <url>` to point at a HyperDX instance.
|
|
76
|
+
After `hdx auth login`, the URL is saved and the flag becomes optional. Run
|
|
77
|
+
`hdx <command> --help` for full flag documentation.
|
|
78
|
+
|
|
79
|
+
### `hdx tui` — Interactive TUI
|
|
80
|
+
|
|
81
|
+
The main event viewer: a searchable, live-tailing table of logs or traces with a
|
|
82
|
+
detail panel, trace waterfall, pattern mining, alerts, and dashboards.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
hdx tui # Pick a source interactively
|
|
86
|
+
hdx tui --source "Logs" # Skip the source picker
|
|
87
|
+
hdx tui -q "level:error" -f # Start with a search query, in follow mode
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Key | Action |
|
|
91
|
+
| ------------- | ------------------------------------------ |
|
|
92
|
+
| `j` / `↓` | Move selection down |
|
|
93
|
+
| `k` / `↑` | Move selection up |
|
|
94
|
+
| `l` / `Enter` | Expand row detail |
|
|
95
|
+
| `h` / `Esc` | Close detail / blur search |
|
|
96
|
+
| `G` / `g` | Jump to newest / oldest |
|
|
97
|
+
| `Ctrl+D/U` | Page down / up |
|
|
98
|
+
| `/` | Search (global in table, filter in detail) |
|
|
99
|
+
| `Tab` | Cycle sources/searches or detail tabs |
|
|
100
|
+
| `Shift+Tab` | Cycle backwards |
|
|
101
|
+
| `t` | Edit time range in `$EDITOR` |
|
|
102
|
+
| `s` | Edit SELECT clause in `$EDITOR` |
|
|
103
|
+
| `Shift+P` | Show event patterns |
|
|
104
|
+
| `Shift+D` | Show generated SQL |
|
|
105
|
+
| `f` | Toggle follow mode (live tail) |
|
|
106
|
+
| `o` | Open trace in browser |
|
|
107
|
+
| `w` | Toggle line wrap |
|
|
108
|
+
| `Shift+A` | Open alerts page |
|
|
109
|
+
| `d` | Open dashboards page |
|
|
110
|
+
| `?` | Toggle help |
|
|
111
|
+
| `q` | Quit |
|
|
112
|
+
|
|
113
|
+
The row detail panel has three tabs — **Overview** (structured OTel attributes),
|
|
114
|
+
**Column Values** (every column of the row), and **Trace** (span waterfall with
|
|
115
|
+
correlated logs, navigable with `j`/`k`).
|
|
116
|
+
|
|
117
|
+
### `hdx chart` — Terminal charts
|
|
118
|
+
|
|
119
|
+
Render charts as terminal output. Designed for troubleshooting from the CLI
|
|
120
|
+
(including by AI agents): visualize a metric, spot the spike, then narrow down
|
|
121
|
+
with `--where` or `hdx query`. All modes run through the same
|
|
122
|
+
`renderChartConfig` pipeline as the web dashboards.
|
|
123
|
+
|
|
124
|
+
Three modes:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 1. Dashboard tiles — render saved tiles from a dashboard
|
|
128
|
+
hdx chart -d "Service Health" # All tiles, past 1h
|
|
129
|
+
hdx chart -d "Service Health" -t "P95 Latency" --since 24h
|
|
130
|
+
|
|
131
|
+
# 2. Ad-hoc builder — chart an aggregation over a source
|
|
132
|
+
hdx chart -s Logs --where 'SeverityText:error' --group-by ServiceName --since 3h
|
|
133
|
+
hdx chart -s Traces --agg quantile --level 0.95 --value Duration \
|
|
134
|
+
--where 'ServiceName:api' --since 6h
|
|
135
|
+
hdx chart -s Logs --display bar --where 'SeverityText:error' --group-by ServiceName
|
|
136
|
+
hdx chart -s Metrics --metric-type sum --metric-name otelcol_exporter_sent_spans
|
|
137
|
+
|
|
138
|
+
# 3. Raw SQL — chart arbitrary queries with time macros
|
|
139
|
+
hdx chart -s Logs --sql "SELECT \$__timeInterval(TimestampTime) AS ts, count()
|
|
140
|
+
FROM default.otel_logs WHERE \$__timeFilter(TimestampTime) GROUP BY ts ORDER BY ts"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- **Display types** (`--display`): `line` (default), `stacked_bar`, `number`,
|
|
144
|
+
`table`, `bar`, `pie`
|
|
145
|
+
- **Time ranges**: `--since 15m|1h|7d`, or `--from`/`--to` with ISO 8601
|
|
146
|
+
(`2026-07-01T00:00:00Z`), dates (`2026-07-01`), or relative values (`now-24h`)
|
|
147
|
+
- **SQL macros**: `$__timeFilter(col)` expands to the selected range,
|
|
148
|
+
`$__timeInterval(col)` buckets by the chart granularity
|
|
149
|
+
- **Output**: ANSI colors are stripped automatically when piping (override with
|
|
150
|
+
`--color always|never`); `--json` emits raw rows + column metadata
|
|
151
|
+
|
|
152
|
+
### `hdx query` — Raw SQL
|
|
153
|
+
|
|
154
|
+
Execute raw ClickHouse SQL through the HyperDX proxy. Output defaults to
|
|
155
|
+
`JSONEachRow` (NDJSON — one JSON object per line), so results pipe cleanly into
|
|
156
|
+
`jq` and friends. Any ClickHouse output format is accepted via `--format`
|
|
157
|
+
(`JSON`, `TabSeparated`, `CSV`, ...).
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
CONN=$(hdx connections --json | jq -r '.[0].id')
|
|
161
|
+
hdx query --connection-id "$CONN" --sql "SELECT count() FROM default.otel_logs"
|
|
162
|
+
hdx query --connection-id "$CONN" --sql "SELECT * FROM default.otel_traces LIMIT 5"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Pattern mining** (`--patterns`): cluster the result into templated log
|
|
166
|
+
patterns using the [Drain](https://github.com/logpai/Drain3) algorithm and emit
|
|
167
|
+
one JSON object per pattern, sorted by count — useful for summarizing thousands
|
|
168
|
+
of rows into a handful of templates:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
hdx query --connection-id "$CONN" --patterns \
|
|
172
|
+
--sql "SELECT Body FROM default.otel_logs LIMIT 10000" --body-column Body
|
|
173
|
+
# {"pattern":"connection <*> closed","count":4823,"sample":"connection 10.0.3.7 closed"}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Exit codes: `0` on success (empty stdout means zero rows), `1` on failure.
|
|
177
|
+
|
|
178
|
+
### `hdx sources` / `hdx connections` / `hdx dashboards` — Discovery
|
|
179
|
+
|
|
180
|
+
List the data sources, ClickHouse connections, and dashboards available to your
|
|
181
|
+
team. All three support `--json` for structured output.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
hdx sources # Sources with ClickHouse CREATE TABLE schemas
|
|
185
|
+
hdx sources --json # Includes column expression mappings per source
|
|
186
|
+
hdx connections --json # Connection IDs for `hdx query` / `hdx chart --sql`
|
|
187
|
+
hdx dashboards # Dashboards + tile names for `hdx chart -d`
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### `hdx auth` — Authentication
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
hdx auth login # Interactive prompts
|
|
194
|
+
hdx auth login -a https://your-hyperdx.example \
|
|
195
|
+
-e user@example.com -p "$PASSWORD" # Non-interactive (CI)
|
|
196
|
+
hdx auth status # Who am I + active team
|
|
197
|
+
hdx auth logout
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The session is saved to `~/.config/hyperdx/cli/session.json` (mode `0600`) and
|
|
201
|
+
reused by all commands until it expires.
|
|
202
|
+
|
|
203
|
+
### `hdx team` — Team switching
|
|
204
|
+
|
|
205
|
+
For users that belong to multiple teams (HyperDX Cloud / EE), switch the team
|
|
206
|
+
that all commands are scoped to — kubectx-style:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
hdx team list # All teams, active one marked
|
|
210
|
+
hdx team current # Print the active team
|
|
211
|
+
hdx team use "My Team" # Switch by name or ID
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The choice persists across CLI invocations. On single-team deployments these
|
|
215
|
+
commands are effectively no-ops.
|
|
216
|
+
|
|
217
|
+
### `hdx upload-sourcemaps` — Source maps
|
|
218
|
+
|
|
219
|
+
Upload JavaScript source maps to HyperDX for stack trace de-obfuscation. Run it
|
|
220
|
+
in your build pipeline:
|
|
10
221
|
|
|
11
222
|
```bash
|
|
12
223
|
npx @hyperdx/cli upload-sourcemaps \
|
|
@@ -16,25 +227,41 @@ npx @hyperdx/cli upload-sourcemaps \
|
|
|
16
227
|
--releaseId "$RELEASE_ID"
|
|
17
228
|
```
|
|
18
229
|
|
|
19
|
-
|
|
230
|
+
| Flag | Description | Default |
|
|
231
|
+
| ------------------------ | ------------------------------------------------------ | ------- |
|
|
232
|
+
| `-k, --serviceKey <key>` | HyperDX service account API key | |
|
|
233
|
+
| `-p, --path <dir>` | Directory containing sourcemaps | `.` |
|
|
234
|
+
| `-u, --apiUrl <url>` | HyperDX API URL (required for self-hosted deployments) | |
|
|
235
|
+
| `-rid, --releaseId <id>` | Release ID to associate with the sourcemaps | |
|
|
236
|
+
| `-bp, --basePath <path>` | Base path for the uploaded sourcemaps | |
|
|
237
|
+
| `--apiVersion <version>` | API version: `v1` (HyperDX V1 Cloud) or `v2` (latest) | `v1` |
|
|
20
238
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"scripts": {
|
|
24
|
-
"upload-sourcemaps": "npx @hyperdx/cli upload-sourcemaps --path=\".next\""
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
```
|
|
239
|
+
Optionally, set the `HYPERDX_SERVICE_KEY` environment variable to avoid passing
|
|
240
|
+
the `--serviceKey` flag.
|
|
28
241
|
|
|
29
|
-
|
|
242
|
+
## For AI agents & scripting
|
|
30
243
|
|
|
31
|
-
|
|
32
|
-
| ------------------------- | ------------------------------------------------------ | ------- |
|
|
33
|
-
| `-k, --serviceKey <key>` | HyperDX service account API key | |
|
|
34
|
-
| `-p, --path <dir>` | Directory containing sourcemaps | `.` |
|
|
35
|
-
| `-u, --apiUrl <url>` | HyperDX API URL (required for self-hosted deployments) | |
|
|
36
|
-
| `-rid, --releaseId <id>` | Release ID to associate with the sourcemaps | |
|
|
37
|
-
| `-bp, --basePath <path>` | Base path for the uploaded sourcemaps | |
|
|
244
|
+
The CLI is built to be driven by scripts and AI agents:
|
|
38
245
|
|
|
39
|
-
|
|
40
|
-
|
|
246
|
+
- `hdx sources --json`, `hdx connections --json`, `hdx dashboards --json`, and
|
|
247
|
+
`hdx team list --json` emit structured output for discovery
|
|
248
|
+
- `hdx query` streams NDJSON by default and documents its exit-code contract
|
|
249
|
+
(`0` success, `1` failure — with "unknown connection" distinguished from "bad
|
|
250
|
+
SQL" on stderr)
|
|
251
|
+
- `hdx query --patterns` compresses large result sets into a few templated
|
|
252
|
+
patterns
|
|
253
|
+
- `hdx chart --json` returns the queried rows + column metadata instead of a
|
|
254
|
+
rendered chart; ANSI colors are stripped automatically when stdout is not a
|
|
255
|
+
TTY
|
|
256
|
+
- Non-interactive login: `hdx auth login -a <url> -e <email> -p <password>`
|
|
257
|
+
|
|
258
|
+
## Links
|
|
259
|
+
|
|
260
|
+
- [HyperDX repository](https://github.com/hyperdxio/hyperdx)
|
|
261
|
+
- [ClickStack documentation](https://clickhouse.com/docs/use-cases/observability/clickstack/overview)
|
|
262
|
+
- [Report an issue](https://github.com/hyperdxio/hyperdx/issues)
|
|
263
|
+
- [Contributing](https://github.com/hyperdxio/hyperdx/tree/main/packages/cli/CONTRIBUTING.md)
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
[MIT](https://github.com/hyperdxio/hyperdx/blob/main/LICENSE)
|