Splunk Search

Can inner join be used to join null fields?

jrodriguezap
Contributor

Hi
Someone may have required this case can support me.
I have the following logs

Aug 27 17:42:40 172.24.20.35 type=A sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:40 172.24.20.35 type=A sessionid=53f2b45b0526 subject="regards"
Aug 27 17:42:40 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:40 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:40 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:45 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:53 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
Aug 27 17:42:53 172.24.20.35 type=B sessionid=53f2b45b0526 [email protected]
And by linking them to an INNER JOIN in SQL as:

index=summary type=A | join type=outer max=0 session_id [ search index=summary type=B ] 
| table session_id  sender subject dst deliver 

I get the following table:

sessionid           sender      subject          dst        deliver
53f2b45b0526  [email protected]  regards  [email protected]
53f2b45b0526  [email protected]  regards  [email protected]
53f2b45b0526  [email protected]  regards  [email protected]
53f2b45b0526  [email protected]  regards                     [email protected]
53f2b45b0526  [email protected]  regards                     [email protected]
53f2b45b0526  [email protected]  regards                     [email protected]

That sentence could be used for the following table?

sessionid           sender      subject          dst          deliver
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]
Tags (3)
1 Solution

musskopf
Builder

Have a look on the "transaction" command. I believe would suites you best!

index=temp sourcetype=syslog | transaction fields=sessionid | table sessionid,sender,subject,dst,deliver

will return

sessionid     sender            subject  dst               deliver
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]
                                         [email protected]  [email protected]
                                         [email protected]  [email protected]

Cheers!

View solution in original post

musskopf
Builder

Have a look on the "transaction" command. I believe would suites you best!

index=temp sourcetype=syslog | transaction fields=sessionid | table sessionid,sender,subject,dst,deliver

will return

sessionid     sender            subject  dst               deliver
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]
                                         [email protected]  [email protected]
                                         [email protected]  [email protected]

Cheers!

jrodriguezap
Contributor

thank you very much Musskopf
The latter option INNER JOIN helped me a lot in getting what he wanted, I had to associate in many fields, but if proved.
Best Regards

0 Karma

musskopf
Builder

The other option is to do a JOIN for each field you need...

index=temp sourcetype=syslog type=B dst=*
| join max=1 type=left sessionod, dst [ search index=temp sourcetype=syslog type=B deliver=* | eval dst=deliver | fields sessionid, dst, deliver ]
| join max=1 type=left sessionid [ search index=temp sourcetype=syslog type=A sender=* | fields sessionid, sender ]
| join max=1 type=left sessionid [ search index=temp sourcetype=syslog type=A subject=* | fields sessionid, subject ]
| table sessionid,sender,subject,dst,deliver

0 Karma

musskopf
Builder

What sort of stats do you need? For mvexpand, you probably need to "|mvexpand dst | mvexpand deliver | where dst=deliver| table..."

0 Karma

jrodriguezap
Contributor

Hi there
Thanks for the data transaction, it is very good, but in this case I have multivalue fields will prevent getting the stats I need at the end of this association.
Also try to do it, then mvexpand, but nothing.
:(

0 Karma

HiroshiSatoh
Champion

Do not use STATS?

(EX.)
index=summary (type=A OR type=B) | stats first(sender) as sender,first(subject) as subject,first(dst) as dst,first(deliver) as deliver,dc(type) as type_count by session_id|search type_count=2|fields - type_count

0 Karma

HiroshiSatoh
Champion

What should I combined to deliver and dst?
Is it okay if values?

index=summary (type=A OR type=B) | stats first(sender) as sender,first(subject) as subject,values(dst) as dst,values(deliver) as deliver,dc(type) as type_count by session_id|search type_count=2|fields - type_count

0 Karma

jrodriguezap
Contributor

Hi HiroshiSatoh
Thanks for your support, look, those commands only show me the first row

sessionid           sender      subject          dst          deliver
53f2b45b0526  [email protected]  regards  [email protected]  [email protected]

it may be?

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!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...