Splunk Search

How to combain two rex

VRP136
Engager

I have two rex queries and want know how to combine

Query : 1

index=test1 sourcetype=teams
| search "osversion="
| rex field=_raw "\s+(?<osVersion>.*?)$"
| table Time(utc) "OSVersion"

output :       

time      osversion
1.1 123
1.2 1234
1.3 12345
1.4 123456

Query : 2

index=test1 sourcetype=teams
| search "host=12*
| rex field=_raw "\w+(?<host>*)$"
| table Time(utc) "OSVersion"

output :       

time      host
1.1 abc
1.2 abcd
1.3 abcde

Pls help me how to combine above queries and should show table like below

time      osversion        host
1.1          123                    abc
1.2          1234                abcd
1.3           12345            abcde

  

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The queries can be combined like this.

index=test1 sourcetype=teams ("osversion=" OR "host=12*")
| rex field=_raw "\s+(?<osVersion>.*?)$"
| rex field=_raw "\w+(?<host>*)$"
| table Time(utc) "OSVersion" host

That will give you lists of OSVersions and hosts separately, but in a single table.  Then you should compare the time values to see if OSVersion and host are in events with the timestamp so they can be merged.  If so, then this query will do it.

index=test1 sourcetype=teams ("osversion=" OR "host=12*")
| rex field=_raw "\s+(?<osVersion>.*?)$"
| rex field=_raw "\w+(?<host>*)$"
| stats values(*) as * by "Time(utc)"
| table "Time(utc)" "OSVersion" host
---
If this reply helps you, Karma would be appreciated.
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!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...