Splunk Search

Comparing index with inputlookup?

danutmatei
Explorer

Hi,

I have a policy.csv file with 2 columns:

user                   tags

Andre               IT

Kleo                  Management

Vlad                  Finance

 

And I also have an index=events with events and field "user"

What I want is to count the number of events for each tag by user.

for example:

User          Tags         Count

Andre         IT           55

 

I've tried this, but it counts the number of rows from the csv, not from index:

|inputlookup policy.csv
| join type=left tags [|tstats count where index=events by user]
|stats count by user tags
Labels (3)
0 Karma

danutmatei
Explorer

Error in 'lookup' command: Must specify one or more lookup fields.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Sorry, try it this way

|tstats count where index=events by user
| lookup policy.csv user
0 Karma

danutmatei
Explorer

bot working, I get 0 statistics

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What is your current search?

0 Karma

danutmatei
Explorer
|tstats count where index=events by user
| lookup policy.csv user
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Does this return any results?

|tstats count where index=events by user

If not, how about this

index=events
| stats count by user
0 Karma

danutmatei
Explorer

And what should I do with this query ? since is not solving my issue and the lookup file is not included ?!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you are not getting any results from the tstats or the stats, then the lookup isn't going to make any difference. You need to look at why there are no results. Perhaps the fields don't exist or are spelt differently, including differences in upper and lower case.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Would this work for you?

|tstats count where index=events by user
| lookup policy.csv
0 Karma

danutmatei
Explorer

no

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

In what way does it not work? What else can you tell us about your data which might help us suggest a more meaningful solution?

0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...