A lightweight, zero-dependency Go CLI for querying Azure Data Explorer (Kusto) via the REST API v2.
- No SDK dependencies — uses raw HTTP calls to the Kusto v2 REST API, only stdlib
- Azure CLI authentication — obtains a bearer token via
az account get-access-token - Multiple input modes — inline query (
-e), script file (-s), or piped stdin - Output formats — ASCII table, CSV, or JSON
- Script mode — execute multiple semicolon-separated queries from a
.kqlfile - Auto-inference — detects
cluster('...')anddatabase('...')in your KQL so-cand-dflags become optional
Download a binary from the latest release — pre-built for Linux, macOS, and Windows (amd64 & arm64).
Or install with Go:
go install github.com/danielsada/go-kusto-cli@latestOr build from source:
git clone https://github.com/danielsada/go-kusto-cli.git
cd go-kusto-cli
make build- Go 1.23+ (build only)
- Azure CLI installed and logged in (
az login) - Permissions to query the target Kusto cluster
# Simple inline query — results printed as an ASCII table
go-kusto-cli -c https://mycluster.westus.kusto.windows.net -d MyDB \
-e "StormEvents | take 10"go-kusto-cli -c <cluster> -d <database> [-e <query> | -s <script>] [-f table|csv|json] [-o <file>]
| Flag | Description | Default |
|---|---|---|
-c |
Kusto cluster URL (optional if cluster('...') is in the query) |
— |
-d |
Database name (optional if database('...') is in the query) |
— |
-e |
Inline KQL query | — |
-s |
Path to a .kql script file |
— |
-f |
Output format: table, csv, json |
table |
-o |
Write output to a file instead of stdout | stdout |
When multiple inputs are available, the CLI resolves them in this order:
-eflag (inline query)-sflag (script file)- stdin (piped input)
Export to CSV:
go-kusto-cli -c https://mycluster.westus.kusto.windows.net -d MyDB \
-e "StormEvents | count" -f csv -o results.csvJSON output:
go-kusto-cli -c https://mycluster.westus.kusto.windows.net -d MyDB \
-e "StormEvents | take 5" -f jsonPipe a query via stdin:
echo "StormEvents | count" | go-kusto-cli -c https://mycluster.westus.kusto.windows.net -d MyDBRun a script file with multiple queries (separated by ; or blank lines):
// queries.kql
StormEvents | count
;
StormEvents | take 10go-kusto-cli -c https://mycluster.westus.kusto.windows.net -d MyDB -s queries.kqlAuto-infer cluster and database from the query — no flags needed:
go-kusto-cli -e "cluster('mycluster').database('MyDB').StormEvents | take 10"# Works with full URLs too
echo "cluster('https://mycluster.westus.kusto.windows.net').database('Logs').Events | count" \
| go-kusto-cli┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Input │──▶│ Auth │──▶│ Client │──▶│ Parser │──▶│ Formatter│
│ Resolver │ │ (az CLI) │ │ (REST v2)│ │ (frames) │ │(tbl/csv/ │
│ │ │ │ │ │ │ │ │ json) │
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘
- Input — resolves the query from
-e,-s, or stdin; infers cluster/database fromcluster()/database()calls - Auth — obtains a bearer token via
az account get-access-token --resource https://api.kusto.windows.net - Client — sends
POST <cluster>/v2/rest/querywith{db, csl}payload - Parser — decodes the Kusto frame-based JSON response and extracts the
PrimaryResulttable - Formatter — renders the result as an ASCII table, CSV, or JSON to stdout or a file
make lint # golangci-lint (errcheck, staticcheck, revive, …)
make vet # go vet
make test # go test -race
make build # build binary
make all # lint + vet + test + buildSee CONTRIBUTING.md for full guidelines.
MIT © Daniel Sada