Splunk Search

Field not in logs but we need it from csv

ksharma7
Path Finder

I am using the below query :

index=rxc  sourcetype="rxcapp" type=ERROR [| inputlookup abc.csv | rename id as i_d | fields i_d] | stats count by i_d type description

Now question is I have abc.csv which has columns id and name, for one name there are many unique id available.

In my logs, the only id is getting logged as i_d so I have used the above query but I want to get count by name instead if id from my logs and name is not getting logged, is there any way I can do that?

Labels (1)
Tags (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Once you have the table

i_d type description count

you could do

|lookup abc.csv id as i_d

and that would then add the column name to the table. If you then want to count by name you can then do

| stats sum(count) as count by name

which will give you name, count

but at that point you will lose type and description, so it depends what you want to do with those fields. You can of course do

| stats sum(count) as couny by name, type, description

 and you could also add in the unique values of id with

| stats sum(count) as count list(id) as ids by name, type, description

Hope this helps.

 

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Once you have the table

i_d type description count

you could do

|lookup abc.csv id as i_d

and that would then add the column name to the table. If you then want to count by name you can then do

| stats sum(count) as count by name

which will give you name, count

but at that point you will lose type and description, so it depends what you want to do with those fields. You can of course do

| stats sum(count) as couny by name, type, description

 and you could also add in the unique values of id with

| stats sum(count) as count list(id) as ids by name, type, description

Hope this helps.

 

0 Karma

ksharma7
Path Finder

Yep worked. Thanks

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...