Splank
CLI tool for querying Splunk logs.
Install
uv tool install splank
Setup
splank init
This creates ~/.config/splank/credentials.toml with your Splunk credentials.
To add a single profile without opening an editor, pass a name (and optionally a host) instead:
splank init qa mystack # bare stack names expand to <name>.splunkcloud.com
splank init qa splunk-qa.example.com
This runs a short wizard (token only — it prompts just for the token), tests the connection before saving, and appends the profile to your existing credentials file (creating it if needed). It offers to overwrite if the name already exists, and to set the new profile as default_profile.
Configuration
The credentials file supports multiple profiles. Each profile authenticates either with a Splunk auth token (HTTP Authorization: Bearer …) or with username + password — set one or the other:
default_profile = "prod"
[profiles.prod]
host = "splunk.example.com"
port = 8089
token = "your-token-here"
verify_ssl = true
[profiles.qa]
host = "splunk-qa.example.com"
port = 8089
username = "admin"
password = "changeme"
verify_ssl = true
Usage
# Search (uses default profile)
splank search 'index=main Level=ERROR' -m 10
# Search using specific profile
splank -p qa search 'index=main Level=ERROR'
# Paste a Splunk web UI URL directly — query and time range are extracted
splank search 'https://splunk.example.com/en-US/app/search/search?q=search%20index%3Dmain&earliest=-30d%40d&latest=now'
# Discover indexes
splank discover 'web*'
# Discover with field info
splank discover 'app-*' --fields -o DISCOVERY.md
# Manage jobs
splank jobs
splank clear
Commands
init- Create credentials file, orinit <name> [host]to add one profile via a short token-only wizardsearch- Execute SPL querydiscover- Discover available indexesjobs- List search jobsclear- Clear my search jobsmcp- Interact with a Splunk MCP server (see below)ask- Ask a free-form question; generates SPL via MCP/SAIA and runs it (see below)
MCP
Splunk instances can expose an MCP server at a URL like
https://<host>/en-US/splunkd/__raw/services/mcp. This is separate from the regular management-port
REST API, and typically needs its own bearer token — a plain Splunk API token is usually rejected
because its audience doesn't match what the MCP endpoint expects.
# Set up a new profile with MCP in one go: derives the MCP URL from the host
# and only prompts for the MCP token
splank init qa splunk-qa.example.com --mcp
# Or add MCP to an existing profile (prompts if url/token omitted)
splank -p qa mcp set https://splunk-qa.example.com/en-US/splunkd/__raw/services/mcp <token>
# List the tools the server exposes
splank -p qa mcp tools
# Call a tool (arguments as key=value; values are parsed as JSON when possible)
splank -p qa mcp call splunk_get_info
splank -p qa mcp call splunk_run_query 'query=search index=main | head 5' row_limit=5
This adds mcp_url and mcp_token to the profile's TOML block, alongside its existing host/token:
[profiles.qa]
host = "splunk-qa.example.com"
port = 8089
token = "your-token-here"
verify_ssl = true
mcp_url = "https://splunk-qa.example.com/en-US/splunkd/__raw/services/mcp"
mcp_token = "your-mcp-scoped-token"
Ask
ask uses the MCP server's saia_generate_spl tool (Splunk AI Assistant) to turn a free-form
question into SPL, prints the generated query, and then runs it through the same pipeline as
search — so all of search's options (--format, --earliest/--latest, --zoom, etc.) apply.
This requires the profile's mcp_url/mcp_token to already be configured (see MCP above,
splank mcp set) — ask connects to that same MCP server to generate the SPL.
splank -p qa ask "show me recent errors in alusta_logs"
splank -p qa ask "find failed logins" --dry-run # only print the generated SPL, don't run it
Search Options
splank search 'index=main Level=ERROR' [options]
| Option | Description |
|---|---|
-e, --earliest |
Earliest time (default: -24h) |
-l, --latest |
Latest time (default: now) |
-m, --max-results |
Max results (default: 100) |
-f, --format |
Output format: json, csv, table, toon (default: toon) |
-o, --output |
Output file (default: stdout) |
--internal |
Include internal Splunk fields (_bkt, _cd, etc.) |
-w, --width |
Truncate field values to N chars (default: 500, 0=no limit) |
-z, --zoom |
Parse JSON from _raw and output as toon |
By default, internal Splunk fields (_bkt, _cd, _indextime, _serial, _si, _sourcetype, _subsecond) are hidden. Use --internal to show them.
The --zoom flag is useful when log lines contain JSON - it extracts and parses the JSON from _raw, outputs as toon format (compact and human-readable), and ignores Splunk metadata.
Global Options
-p, --profile- Splunk profile to use (e.g., 'qa', 'prod')-V, --version- Show version
Release files for splank 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| splank-0.5.1.tar.gz | 44.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| splank-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.7 kB
Release files / splank-0.5.1.tar.gz
| Download URL | splank-0.5.1.tar.gz |
|---|---|
| Size | 44.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a1b26e640fb0a5a8173add7cc2a14b5ff76dabd3a9fa4a4b86239bfd4ebb0ef
|
|
BLAKE2b-256 checksum How to use checksums |
ccf38861fc15a3ddadbf4dd40c71df61e837e7bbc2d33e4a8b281a71a20bd8b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / splank-0.5.1-py3-none-any.whl
| Download URL | splank-0.5.1-py3-none-any.whl |
|---|---|
| Size | 52.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24a4380273911ca7a470e188da0e7e7022a31fd87386f481448f0d65ca54903f
|
|
BLAKE2b-256 checksum How to use checksums |
a0784791dfeb668be5a818a5c009997503d69c6be7ad8628fe7ceb878fd76046
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|