Splunk Search

Return something when search doesn't return anything

jordans
Path Finder

I want to have a table with results of a search of the SQL logs for backups. But the search I have only returns the successful backups. I want to display a line in the table if a backup failed, i.e. if a database name does NOT appear in the search results.

Is this possible? I tried an 'append', but the last line is repeated if the search term is not found.

Tags (1)
0 Karma
1 Solution

jordans
Path Finder

My own comment of 'set math' set me on a path to the "set union" command. I now search for successes and failures and combine to a single table.

I have not answered my original question, but I have a work around for my current problem.

View solution in original post

0 Karma

jordans
Path Finder

My own comment of 'set math' set me on a path to the "set union" command. I now search for successes and failures and combine to a single table.

I have not answered my original question, but I have a work around for my current problem.

0 Karma

eelisio2
Path Finder

Do you have (or can generate) a list of all Database Names?
You could index that list.
Extract the database name from the backup logs. Use the same fieldname (e.g., db_name) in both sourcetypes (the list of all databases and the backup log)

The following should give you a list of database names from the alldatabases sourcetype that aren't matched in the backuplog sourcetype.

sourcetype="alldatabases" | join type=outer db_name [search sourcetype=backuplog] | search sourcetype=alldatabases | table db_name
0 Karma

eelisio2
Path Finder

I'm glad that you found a different solution. The search from my answer will work as well. There needs to be a common field name for the join command to work.

Note that if you run my search without " | search sourcetype=alldatabases | table db_name", the result set has a mix of the 2 sourcetypes. The rows with the sourcetype="alldatabases" did not find a match in the other sourcetype. So, the extra search command at the end should filter the results accordingly.

0 Karma

jordans
Path Finder

I don't think the set math works. I get a list of all databases from the database list.

To test, I added a bogus database name to a txt file of valid db names, indexed it, and performed your search.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...