Skip to main content
Like AOF? Give us a star!
If you find AOF useful, please star us on GitHub. It helps us reach more developers and grow the community.

Splunk Tools

AOF provides native Splunk integration tools for executing SPL queries, managing alerts, running saved searches, and sending events via HTTP Event Collector (HEC).

Feature Flag Required: These tools require the siem feature flag to be enabled during compilation.

Prerequisites

  • Splunk deployment (Cloud or Enterprise)
  • Splunk authentication token or credentials
  • Network access to Splunk REST API (port 8089) and HEC (port 8088)

Authentication

Splunk supports multiple authentication methods:

env:
SPLUNK_TOKEN: "${SPLUNK_AUTH_TOKEN}"

Splunk Token

Authorization: Splunk <token>

Basic Auth

Authorization: Basic <base64(username:password)>

HEC Token (for event ingestion)

env:
SPLUNK_HEC_TOKEN: "${SPLUNK_HEC_TOKEN}"

Network Ports

PortServiceDescription
8089REST APIManagement and search operations
8088HECHTTP Event Collector for event ingestion

Available Tools

ToolDescriptionUse Cases
splunk_searchExecute SPL queriesLog analysis, security investigation
splunk_alerts_listList fired alertsIncident response, alert monitoring
splunk_saved_searchesList saved searchesSearch inventory, management
splunk_saved_search_runRun a saved searchOn-demand analysis, scheduled execution
splunk_hec_sendSend events via HECEvent ingestion, audit logging
splunk_indexes_listList available indexesData source discovery

Execute SPL (Search Processing Language) queries against Splunk data. Searches are asynchronous - the tool handles job creation, polling, and result retrieval automatically.

Parameters:

ParameterTypeRequiredDescription
base_urlstringYesSplunk REST API URL (e.g., https://splunk:8089)
tokenstringYesSplunk authentication token
querystringYesSPL search query
earliest_timestringNoStart time (default: -1h)
latest_timestringNoEnd time (default: now)
max_countintegerNoMaximum results (default: 1000)

Time Format Options:

  • Relative time: -1h, -1d@d, -30m
  • Absolute time: 2025-12-25T00:00:00
  • Snap-to: @d (midnight), @h (hour)
  • Current time: now

Example SPL Queries:

# Error logs from web servers
index=web sourcetype=access_combined status>=500 | stats count by host

# Security events with failed actions
index=security action=failure | timechart count by user

# Application metrics
index=metrics source="app_metrics" | stats avg(response_time) by endpoint

# Transactions spanning multiple events
index=web | transaction startswith="start" endswith="end"

Example Agent Configuration:

apiVersion: aof.dev/v1
kind: Agent
metadata:
name: splunk-analyst-agent
spec:
model: google:gemini-2.5-flash
instructions: |
You are a Splunk log analysis agent.

Use SPL queries to:
- Search for errors and anomalies
- Analyze access patterns
- Investigate security events
- Generate statistics and trends

Common SPL patterns:
- `stats count by field` - Aggregate counts
- `timechart span=1h count` - Time-based charts
- `rex field=_raw "pattern"` - Extract fields
- `transaction startswith="..." endswith="..."` - Group related events

tools:
- splunk_search
- splunk_indexes_list

env:
SPLUNK_BASE_URL: "${SPLUNK_URL}"
SPLUNK_TOKEN: "${SPLUNK_TOKEN}"

splunk_alerts_list

List fired/triggered alerts from Splunk.

Parameters:

ParameterTypeRequiredDescription
base_urlstringYesSplunk REST API URL
tokenstringYesSplunk authentication token
countintegerNoNumber of alerts to retrieve (default: 50)

Example Agent Configuration:

apiVersion: aof.dev/v1
kind: Agent
metadata:
name: splunk-security-agent
spec:
model: google:gemini-2.5-flash
instructions: |
You are a Splunk security analysis agent.

Capabilities:
1. List fired security alerts
2. Run security-related searches
3. Analyze attack patterns

Focus on:
- Failed authentication attempts
- Unusual access patterns
- Privilege escalation
- Data exfiltration indicators

tools:
- splunk_alerts_list
- splunk_search
- splunk_saved_search_run

splunk_saved_searches

List configured saved searches in Splunk.

Parameters:

ParameterTypeRequiredDescription
base_urlstringYesSplunk REST API URL
tokenstringYesSplunk authentication token
searchstringNoFilter by name pattern
countintegerNoNumber of results (default: 50)

splunk_saved_search_run

Execute a pre-configured saved search.

Parameters:

ParameterTypeRequiredDescription
base_urlstringYesSplunk REST API URL
tokenstringYesSplunk authentication token
namestringYesSaved search name
trigger_actionsbooleanNoTrigger alert actions (default: false)

splunk_hec_send

Send events to Splunk via HTTP Event Collector for ingestion.

Parameters:

ParameterTypeRequiredDescription
hec_urlstringYesHEC endpoint URL (e.g., https://splunk:8088)
hec_tokenstringYesHEC token (GUID format)
eventobjectYesEvent data to send
sourcestringNoEvent source (default: aof)
sourcetypestringNoEvent sourcetype (default: aof:event)
indexstringNoTarget index
hoststringNoHost value for the event

Example Agent Configuration:

apiVersion: aof.dev/v1
kind: Agent
metadata:
name: splunk-logger-agent
spec:
model: google:gemini-2.5-flash
instructions: |
You are a Splunk event logging agent.

Send structured events to Splunk for:
- Agent activity logging
- Task completion events
- Error and exception events
- Audit trail

Always include:
- Timestamp
- Agent name
- Action type
- Status
- Relevant context

tools:
- splunk_hec_send

env:
SPLUNK_HEC_URL: "${SPLUNK_HEC_URL}"
SPLUNK_HEC_TOKEN: "${SPLUNK_HEC_TOKEN}"

splunk_indexes_list

List available Splunk indexes to discover data sources.

Parameters:

ParameterTypeRequiredDescription
base_urlstringYesSplunk REST API URL
tokenstringYesSplunk authentication token

Pre-built Agents

For production-ready agents using these tools, see the Agent Library:

# Run the pre-built agent
aofctl run agent library://observability/splunk-analyst \
--prompt "Search for error logs in the last hour"

Rate Limits

  • REST API: Deployment-specific (no hard default limits)
  • Search Concurrency: Typically 5-10 concurrent searches
  • Result Limit: 50,000 rows per search
  • HEC: High throughput, batching recommended

Best Practices

  1. Always use time bounds: Include earliest_time and latest_time
  2. Use export for large results: For streaming large datasets
  3. Limit fields: Use | fields to reduce data transfer
  4. Paginate results: Use offset and count parameters
  5. Batch HEC events: Send multiple events in single requests

Security Considerations

  1. Token Management: Store tokens in environment variables
  2. Service Accounts: Use accounts with minimal permissions
  3. Token Rotation: Rotate tokens periodically
  4. Network Security: Always use HTTPS, validate SSL certificates

See Also