Splunk Search

How to achieve searching multiple indexes with one table?

mw98
Explorer

I'm trying to create a table to view hosts in multiple indexes, and report if they are returning data. 

For example

Host    Index1  Index2   Index3

A           OK            OK

B                              OK            OK

C            OK                              OK

 

I've been using inputlookups to create a static list of hosts to reference, and appendcols to search indexes for the correct information. However, when used together the data isn't quite matching up like it does when I search separately. Any Suggestions?

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

About 95% of the time, appendcols is not the right solution to a Splunk problem.  That's because the data doesn't always line up (as you've discovered).

Try this alternative

| tstats count where index=* host=* by host,index 
| eval count=if(count==0, "", "OK")
| xyseries host index count

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

mw98
Explorer

My search is something along the lines of this 

 

|inputlookup serverlist.csv| table server| appendcols [search index=exampleIndex host IN(A B C)| eval statuscheck= if( host = server, "ok", "notok"| table statuscheck]

 

and then I would repeat the appendcols for another index

0 Karma

richgalloway
SplunkTrust
SplunkTrust

About 95% of the time, appendcols is not the right solution to a Splunk problem.  That's because the data doesn't always line up (as you've discovered).

Try this alternative

| tstats count where index=* host=* by host,index 
| eval count=if(count==0, "", "OK")
| xyseries host index count

 

---
If this reply helps you, Karma would be appreciated.

mw98
Explorer

This is what I was looking for! Thank you

richgalloway
SplunkTrust
SplunkTrust

If your problem is resolved, then please click the "Accept as Solution" button to help future readers.

---
If this reply helps you, Karma would be appreciated.
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Don't use appendcols?

Without seeing your searches, my guess would be that some of them are not returning results for all the hosts in the same order?

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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...