Splunk Search

How to combine data from indexes with different fields as common results

sasankganta
Path Finder

Hi Team,

 I have 2 indexes with same data.

In Index1 data is coming with the fields user, action, http_referrer and 

In index 2 data is coming with the fields loginid, action, referrer

I want to table the results with common field data from 2 indexes like | table user, action, referrer 

I tried using eval mvappend it didn't work. Can some one please assist. Thank You. 

Labels (5)
Tags (1)
0 Karma

sasankganta
Path Finder

Hi @gcusello None of the above query are working :

sorry if i confused you I will give you more details here:

Index1 data: may 16 04:00:00 10.10.01 vendor=* product=* user=xxxx action=allowed http_referrer=https:google.com

Index2 data:  may 16 04:00:00 10.10.01 vendor=* product=* LoginID=xxxx action=allowed referrer=https:google.com

In above log data is same but filed names are changed. Now I want to name common filed in my results and I want results in below format in statistics:

   action            user             referrer
  allowed         sasank        https:google.com

  allowed         sasank        https:google.com              

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sasankganta,

let me understand: loginID has the same values of user?

if yes, you can use eval coalesce to gibe the same field name:

index=indexA OR index=indexB
| eval referrer=coalesce(http_referrer,referrer), user=coalesce(user,LoginID)
| stats count BY user action referrer
| fields - count

if they are different:

index=indexA OR index=indexB
| eval referrer=coalesce(http_referrer,referrer)
| stats values(user) AS user BY action referrer
| mvexpand user

Ciao.

Giuseppe

 

0 Karma

sasankganta
Path Finder

Hi @gcusello , Early I tried this as well before posting. It didn't work.

If I'm doing table / stats for the above data :

In Index1 fields user, action, http_referrer and 

In index 2  fields loginid, action, referrer

final result in statistics I need user, action, referrer these 3 fields 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sasankganta,

what do you mean with "it doesn't work"?

it's a result different from the desidered one or there isn't any result?

if you want in each row user, action and referrer, you can use something like this:

index=indexA OR index=indexB
| eval referrer=coalesce(http_referrer,referrer)
| stats count BY user action referrer
| fields - count

if you haven't any result, check the format of http_referrer and referrer: verify if they have the same format.

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sasankganta,

you have to use stats to correlate events from different Data Sources, something like this:

index=indexA OR index=indexB
| eval referrer=coalesce(http_referrer,referrer)
| stats values(user) AS user values(action) AS action BY referrer

if you want to correlate for referrer and user, you can move user field in the BY clause:

index=indexA OR index=indexB
| eval referrer=coalesce(http_referrer,referrer)
| stats values(action) AS action BY user referrer

Ciao.

Giuseppe

 

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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...