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”The CLI is the Python package sondar-cli (2.9.6, Python 3.10+), which
installs a single sondar command.
pip install -e . # from a source checkout of sondar-cli/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.
Which port -e wants. 9200 is the container’s own HTTP port and serves
both the web UI and the API, so http://<host>:9200 is right for a plain
docker run install — that is what the examples above assume. A deployment that
puts a gateway or ingress in front of the container answers on whatever port
that fronts instead (commonly 8080), and the CLI wants the address you open
in a browser, not the container’s internal port. If a config add succeeds but
every later command fails to reach the cluster, that mismatch is the first thing
to check.
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”.