Bajwa Consulting Need senior Oracle DBA help? Performance tuning, Cloud migrations, GoldenGate, backup and DR. Plus 70+ free DBA scripts.
Visit bajwaconsulting.com →

Friday, November 27, 2026

Splunk for DBAs: Basics and the SPL Commands I Use Most

Splunk collects machine data (log files, metrics, events) into indexes and lets you search it with the Search Processing Language (SPL). For a DBA, that means one place to search alert logs, listener logs, OS logs and application errors across every server. This post covers the basics and the SPL commands I use most.

Key terms

TermMeaning
IndexWhere data is stored, for example oracle or os. Always name the index in your search; it is much faster.
SourcetypeThe format of the data, such as oracle:alert or linux_secure. It decides how fields are extracted.
SourceThe file or input the event came from, such as /u01/app/oracle/diag/.../alert_ORCL.log.
HostThe server that sent the event.
EventOne record, usually one log entry, with a timestamp.
FieldA named value in an event, such as host or an extracted ora_error.
ForwarderThe Universal Forwarder agent on each server that sends files to Splunk.

Your first searches

Open Search & Reporting, pick a time range in the time picker (for example "Last 24 hours"), and type:

index=oracle sourcetype=oracle:alert "ORA-"

Search terms are combined with AND by default. Use OR and NOT in capitals, and quotes for exact phrases:

index=oracle ("ORA-00600" OR "ORA-07445") NOT host=testdb*
index=os sourcetype=linux_secure "Failed password"

Click a field in the left sidebar to see its top values, and click a value to add it to the search.

The pipe

Like in a Unix shell, | passes the results of one command to the next. The first part finds events; the commands after the pipes shape them:

index=oracle "ORA-" | stats count by host | sort - count

SPL commands I use most

CommandWhat it doesExample
statsCounts, sums, averages by field| stats count by host
timechartStatistics over time, for a chart| timechart span=1h count by host
top / rareMost or least common values| top limit=10 ora_error
tableShow only chosen fields| table _time host ora_error
sortSort results (- means descending)| sort - count
dedupKeep one event per value| dedup host
rexExtract a field with a regular expression| rex "(?<ora_error>ORA-\d{5})"
evalCalculate a new field| eval gb=round(bytes/1024/1024/1024,2)
whereFilter on a calculated condition| where count > 10
renameRename fields for display| rename count AS "Errors"
head / tailFirst or last N results| head 20
lookupAdd fields from a CSV lookup table| lookup db_owners host OUTPUT team
transactionGroup related events into one| transaction host maxspan=5m

Useful searches for DBAs

ORA- errors in alert logs, by database server and error code:

index=oracle sourcetype=oracle:alert "ORA-"
| rex "(?<ora_error>ORA-\d{5})"
| stats count by host ora_error
| sort - count

Hourly trend of ORA- errors, one line per host:

index=oracle sourcetype=oracle:alert "ORA-"
| timechart span=1h count by host

Databases that restarted in the last 7 days (set the time picker to "Last 7 days"):

index=oracle sourcetype=oracle:alert "Starting ORACLE instance"
| table _time host
| sort - _time

Failed SSH logins on database servers:

index=os sourcetype=linux_secure "Failed password"
| rex "from (?<src_ip>\d+\.\d+\.\d+\.\d+)"
| stats count by host src_ip
| where count > 5

Listener connections per service per hour:

index=oracle sourcetype=oracle:listener "establish"
| rex "SERVICE_NAME=(?<service>[^\)]+)"
| timechart span=1h count by service

SPL does not use -- for comments. To add a comment inside a search, wrap it in three backticks: ```count errors per host```.

Sourcetype names depend on how your Splunk admin set up the inputs. Run index=oracle | stats count by sourcetype to see what you have.

Saving searches, alerts and dashboards

  • Save As → Report keeps a search you run often.
  • Save As → Alert runs the search on a schedule and emails you (or opens a ticket) when there are results. For example: "ORA-00600 in the last 15 minutes, any host".
  • Save As → Dashboard Panel adds the chart to a dashboard, such as a daily database health page.

Tips for fast searches

  • Always start with index= and, if you can, sourcetype=.
  • Use the smallest time range that answers your question.
  • Filter as early as possible, before the first pipe, and use stats rather than transaction when you can.
  • Use | fields host ora_error early to carry only the fields you need.

To practice, Splunk offers a free trial of Splunk Enterprise and free introductory training on its website.

More DBA scripts are in my GitHub repository: github.com/sbajwa55/dba-scripts. For help with Oracle, cloud migrations or AWS, visit Bajwa Consulting Services.

No comments:

Post a Comment