Skip to main content

Quick start

Count HTTP 5xx responses by service in a sample log file. Then store the same events on a server and query them again.

Install​

These examples use the PPL syntax in the current source tree. Build from the LynxDB repository with Go 1.26 or later.

go build -o lynxdb ./cmd/lynxdb
./lynxdb version

See Installation for release binaries, Homebrew, and Docker. Use lynxdb in the examples if you installed it on your PATH.

Query a local file​

Create access.ndjson with one JSON object per line.

cat > access.ndjson <<'NDJSON'
{"status":200,"service":"api"}
{"status":503,"service":"api"}
{"status":502,"service":"api"}
NDJSON

Run this query in the same directory.

./lynxdb query --file access.ndjson '
source=main
| where status >= 500
| stats count() as errors by service' \
--format csv --no-stats
errors,service
2,api

--file loads the input into a temporary index named main. The CLI deletes it on exit. See pipe mode to query stdin or a set of files.

Start a server​

Start LynxDB in one terminal. --data-dir keeps the tutorial's data in a separate directory. The default HTTP address is localhost:3100.

./lynxdb server --data-dir ./quickstart-data

In a second terminal, send the sample file to the web index.

curl -fsS 'http://localhost:3100/api/v1/ingest?index=web' \
-H 'Content-Type: application/x-ndjson' \
--data-binary @access.ndjson

Run the same aggregation against web. With no file or pipe input, the CLI sends the query to the server.

./lynxdb query '
source=web
| where status >= 500
| stats count() as errors by service' \
--format csv --no-stats

The result is again 2,api after a single upload. Stop the server with Ctrl+C when you're done. The events stay in quickstart-data.

Read a query​

source=web selects an index. where status >= 500 keeps matching events. stats count() as errors by service groups them by service and names the count column errors.

Next steps​