Splunk Search

Could not construct lookup error for Top 10 users in Past 30 days

anikeshp7
Path Finder

Hi,

Im trying to display display top 10 users Name in the past 30 days using query

index="123" AND organizationId="00980876655334" earliest=-30d logRecordType=axapx ((*DataTableController*) AND (*fetchData*)) |lookup Test.csv UserID AS userId OUTPUT Name AS NAME| stats count(userId) as usage by userId |sort -usage limit=10

In Test.csv I have columns UserId and Name containing userIds and respective Names of users

The above query succesfully returns the top 10 UserId. However my requirement is to return the Names instead of the userIds.

tweaking the last line of query as [ stats count(NAME) as usage by NAME |sort -usage limit=10 ]

doesn't seem to work and gives error "Could not construct lookup 'Test.csv, UserID, AS, userId, OUTPUT, Name, AS, NAME'. "

Can anyone please help me on this.

 

 

Labels (5)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try putting the lookup after stats.  It's a good practice to perform lookups late in query so fewer events have to be looked up.

index="123" AND organizationId="00980876655334" earliest=-30d logRecordType=axapx ((*DataTableController*) AND (*fetchData*)) 
| stats count(userId) as usage by userId 
| sort - usage limit=10
| lookup Test.csv UserID AS userId OUTPUT Name AS NAME
| table NAME, usage
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try putting the lookup after stats.  It's a good practice to perform lookups late in query so fewer events have to be looked up.

index="123" AND organizationId="00980876655334" earliest=-30d logRecordType=axapx ((*DataTableController*) AND (*fetchData*)) 
| stats count(userId) as usage by userId 
| sort - usage limit=10
| lookup Test.csv UserID AS userId OUTPUT Name AS NAME
| table NAME, usage
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...