Skip to main content

Overview

OpenSRE queries Splunk over the REST API. When you ask about logs, the agent writes an SPL query and calls query_splunk_logs. There is no opensre integrations setup splunk handler today. Configure Splunk via environment variables or the integration store, then verify with opensre integrations verify splunk.

Prerequisites

  • Splunk Enterprise or Splunk Cloud (version 8.x or later)
  • REST API access on port 8089
  • A bearer token with search capability (see Credentials)

Setup

Option 1: Environment variables

Option 2: Persistent store

Option 4: Multi-instance

When SPLUNK_INSTANCES is set it overrides the single-instance SPLUNK_URL / SPLUNK_TOKEN variables.

Credentials

OpenSRE uses bearer tokens — not basic auth and not HEC tokens. Via the Splunk UI:
  1. Go to SettingsTokens
  2. Click New Token
  3. In User, pick the existing Splunk user the token authenticates as
  4. Fill in Audience (required) and an expiry date
  5. Copy the generated token
Via the REST API (replace <PASSWORD> with your admin password and <SPLUNK_USER> with the service account the token should authenticate as):
name is the existing Splunk user the token authenticates as, not an arbitrary label — Splunk rejects an unrecognized name with User "..." does not exist. The token inherits that user’s roles, so point it at a least-privilege service account rather than admin. audience is also required (a short free-text description of the token’s purpose); omitting it fails with The following required arguments are missing: audience.
The token needs the search capability. The admin role includes this by default. For a dedicated service account, ensure the role includes:
  • search
  • read_splunkd_private_settings (needed for the verify call against /services/server/info)

Quick local test with Docker

splunk/splunk publishes amd64 only, which is why --platform linux/amd64 is already on the command above. On Apple Silicon it runs under emulation and can take 15 minutes or more to report ready; on native amd64 the flag is a harmless no-op. Without SPLUNK_GENERAL_TERMS=--accept-sgt-current-at-splunk-com alongside SPLUNK_START_ARGS=--accept-license, the container exits immediately with License not accepted — newer images require both, not just the license flag documented in older Splunk Docker guides.
Seed a test event and create a token:
Then point OpenSRE at an empty store, so the container is the only Splunk either command can reach:
Do this before verifying, and keep it for the rest of the recipe. A saved Splunk record wins over SPLUNK_URL / SPLUNK_TOKEN for opensre integrations verify, so with your real store in play the check can pass against production while appearing to test localhost — the SOURCE column reads local store instead of local env. Chat sessions fail the other way: they only fall through to env vars when the store has no records at all, so a single record for any unrelated service blocks env resolution entirely. An empty store is the one state both surfaces agree on. SPLUNK_INSTANCES overrides SPLUNK_URL / SPLUNK_TOKEN outright, which is why the block above clears it.
Verify:
Now ask the agent about the seeded event:
Ask: Search Splunk for payment-service errors in the last hour. The agent writes the SPL, calls query_splunk_logs, and surfaces the seeded connection refused to billing-api event from this exact local instance. Teardown:

Tools

query_splunk_logs

The agent writes the SPL query and calls the tool. OpenSRE does not build SPL from a fixed priority table.

Verify

Expected output:

Troubleshooting

Security

  • Use a read-only bearer token — never use an admin token in production.
  • Store SPLUNK_TOKEN in .env or the credential store, not in source code or CI logs.
  • Prefer a dedicated opensre service account with only the search capability (plus read_splunkd_private_settings for verify).
  • For enterprise self-signed certificates, set SPLUNK_CA_BUNDLE rather than disabling verification entirely.
  • Set SPLUNK_VERIFY_SSL=false only in local or dev environments when you cannot supply a CA bundle.
  • Rotate tokens on a schedule and revoke them when no longer needed.