The Sondar CLI
The Sondar CLI
Section titled “The Sondar CLI”sondar is the command-line client for a Sondar cluster — search, write data,
manage resources, and run saved queries from a script or a terminal. Useful for
automation, and for operations where the web UI is not the right surface.
Install
Section titled “Install”pip install -e .This installs the sondar command from the sondar-cli distribution.
Connect to a cluster
Section titled “Connect to a cluster”Configuration lives in ~/.sondar/config.yaml. A password is never written
there — only the token it generates.
# with an existing tokensondar config add -n prod -e http://localhost:9200 -t <token>
# with a username; you are prompted for the password and a token is createdsondar config add -n prod -e http://localhost:9200 -u myuser
sondar config list # all configured clusterssondar config use -n prod # set the defaultsondar config remove -n prodPass -c <name> to any command to override the default cluster for one call.
Search
Section titled “Search”sondar search 'repo=test01 | limit 10'sondar search 'repo=test01 | limit 10' --format jsonsondar search 'search2 repo="*" | stats count() as cnt by repo | sort by cnt | limit 10' -w --interval 1--format accepts table, text, json, csv, html and latex.
-w/--watch re-runs the query on an interval. See
SonQL for the query language.
Write data
Section titled “Write data”sondar insert --repo test01 '[{"a":1}]'echo 'error: disk full' | sondar insert --repo test01Manage resources
Section titled “Manage resources”sondar asset covers 61 resource types — indexes, users, alerts, dashboards,
and the rest — each exposing the verbs its API supports:
sondar asset # list the resource typessondar asset repos list # indexessondar asset repos create --name test_reposondar asset users listsondar asset alerts create --help # per-resource optionsSaved queries and skills
Section titled “Saved queries and skills”sondar sonql list # the built-in SonQL queriessondar sonql query slow-queries
sondar skills list # agent skills that ship with the CLIsondar skills get sondar-cli-troubleshootsondar skills install -aMock data
Section titled “Mock data”sondar mock --repo test01 --type logExit codes
Section titled “Exit codes”0 on success, 1 on a runtime or authentication failure, 2 on a usage
error — so scripts can tell “worked” from “failed” from “typed wrong”.