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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...