Skip to main content

CLI Overview

LynxDB ships as a single binary that covers every workflow -- pipe-mode analytics, persistent server, cluster node, interactive shell, and admin tooling. No separate installers, no plugins.

lynxdb [command] [flags]

Modes of Operation

The CLI works in three distinct modes depending on the command and context:

1. Server mode

lynxdb server

Starts a persistent HTTP server. Data is stored on disk (or in-memory if data_dir is empty). Other commands (query, ingest, status, etc.) connect to this server over HTTP.

2. Local file mode

lynxdb query --file access.log '| stats count by status'

Queries run directly against local files without a running server. LynxDB creates an ephemeral in-memory engine, ingests the file(s), executes the query, and exits.

3. Stdin pipe mode

cat app.log | lynxdb query '| stats count by level'

Same as file mode, but reads data from stdin. Detected automatically when stdin is not a terminal. No server required.

Global Flags

Available on all commands:

FlagShortDefaultEnv VarDescription
--config(auto)Path to config file
--serverhttp://localhost:3100LYNXDB_SERVERLynxDB server address
--tokenLYNXDB_TOKENAPI key for authentication
--profile-pLYNXDB_PROFILEConnection profile name
--format-FautoOutput format: auto, json, ndjson, table, csv, tsv, raw
--quiet-qfalseSuppress non-data output
--verbose-vfalseShow extra detail
--no-statsfalseSuppress query statistics
--no-colorfalseDisable colored output
--debugfalseEnable debug logging to stderr
--tls-skip-verifyfalseLYNXDB_TLS_SKIP_VERIFYSkip TLS certificate verification

TTY Detection and Output Behavior

LynxDB adjusts its output based on whether stdout is a terminal (TTY) or a pipe:

TTY (interactive terminal):

  • --format auto renders colorized JSON with numbered results and a stats footer
  • Query commands show a live progress spinner with segment scan stats
  • Commands like ingest show progress bars

Pipe (non-TTY):

  • --format auto outputs newline-delimited JSON (one object per line)
  • No colors, no spinners, no progress bars
  • Stats and metadata go to stderr so they do not pollute piped data
# TTY -- colorized JSON with stats
lynxdb query 'level=error | stats count by source'

# Pipe -- clean NDJSON to jq
lynxdb query 'level=error | stats count by source' | jq '.source'

# Force a specific format regardless of TTY
lynxdb query 'level=error | stats count by source' --format table

The NO_COLOR environment variable disables colored output when set to any non-empty value.

To disable the TUI and get plain output in a terminal:

lynxdb query 'FROM main | stats count' --format json
# or pipe through cat:
lynxdb query 'FROM main | stats count' | cat

Exit Codes

CodeNameMeaning
0OKCommand completed successfully
1GeneralUnspecified failure
2UsageInvalid flags or missing arguments
3ConnectionCannot reach server
4QueryParseBad SPL2 syntax
5QueryTimeoutServer timeout or --timeout exceeded
6NoResultsQuery returned 0 results (with --fail-on-empty)
7AuthMissing or invalid authentication token
10AbortedUser declined destructive action confirmation
124TimeoutGeneric timeout (GNU convention)
130InterruptedUser pressed Ctrl+C (SIGINT)

Usage in scripts:

lynxdb query 'level=FATAL' --fail-on-empty 2>/dev/null
case $? in
0) echo "Fatal errors found!" ;;
6) echo "No fatal errors" ;;
3) echo "Server unreachable" ;;
*) echo "Unexpected error" ;;
esac

Signal Handling

ContextSignalAction
lynxdb serverSIGINT / SIGTERMGraceful shutdown (finish in-flight requests, flush, exit)
lynxdb serverSIGHUPHot-reload configuration from file
lynxdb demoSIGINT / SIGTERMStop generation, print summary, exit
lynxdb query / tail / watch / topSIGINTCancel current operation, exit

Command Map

CategoryCommands
Core dataquery, ingest, import
Real-timetail, top, watch, diff
Quick accesscount, sample, last, fields, explain, examples
Server & opsserver, status, health, indexes, cache
Materialized viewsmv
Alertsalerts
Configurationconfig, doctor
Interactiveshell
Performancebench, demo
Output--format
Setupinstall, uninstall
Completioncompletion

SPL Compatibility Hints

When using file/stdin query mode, LynxDB detects common Splunk SPL1 syntax and prints compatibility hints to stderr:

hint: "index=main" is Splunk SPL syntax. In LynxDB SPL2, use "FROM main" instead.

This helps users transitioning from Splunk. Run lynxdb examples for a full SPL2 cookbook.