Skip to content

Add built-in result formatting options #6

@jessitron

Description

@jessitron

Problem

All results are returned as JSON, which requires piping through jq for every query to make them human-readable. While JSON is great for scripting, it's tedious for interactive investigation:

# This is verbose and repetitive:
hccli create-query-result --dataset frontend --query-id xyz | jq '.data.results[] | {endpoint: .data."http.target", p99: .data."P99(duration_ms)"}'

Real-World Example

While investigating latency, I ran dozens of queries and had to write custom jq expressions each time to view results in a readable format. This added significant friction to the investigation flow.

Proposed Solution

Add a --format flag with built-in formatters:

Table format

hccli create-query-result --dataset frontend --query-id xyz --format table

Output:

┌─────────────────┬─────────────┬───────┐
│ Endpoint        │ P99 (ms)    │ Count │
├─────────────────┼─────────────┼───────┤
│ /cart/checkout  │ 3,904       │ 5,409 │
│ /cart           │   771       │ 17,629│
│ /               │   828       │ 4,682 │
└─────────────────┴─────────────┴───────┘

CSV format

hccli create-query-result --dataset frontend --query-id xyz --format csv

Easy to import into spreadsheets or other tools.

Summary format

hccli create-query-result --dataset frontend --query-id xyz --format summary

Output:

Total results: 42
Time range: 2024-02-11 18:00:00 - 18:45:00
Top 5 by P99 latency:
  1. /cart/checkout: 3,904ms (5,409 requests)
  2. /cart: 771ms (17,629 requests)
  ...

JSON (default)

hccli create-query-result --dataset frontend --query-id xyz --format json
# Current behavior, for backward compatibility

Why This Helps

  • Faster investigations: Immediately see readable results without jq
  • Better discoverability: New users don't need to learn jq
  • Still scriptable: JSON remains default for pipes/automation
  • Reduced cognitive load: Focus on data, not formatting

Implementation Note

Could use libraries like:

  • tablewriter for ASCII tables

  • Built-in encoding/csv for CSV

  • Template system for custom formats

  • claude

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions