Splunk Search

Can you help me optimize this query without join using stats and OR?

m4sucess
New Member

index="index1" sourcetype=show_command
| join id [ search index="index2" sourcetype=software_data ]
| sort _time
| stats last(state) as state by name, device_id, interface
| where state != "UP"
| dedup name
| stats count

I want to optimize this query with without join using stats and OR, can anyone help me?

Here index1 has fields like id,device_id and interface
index2 has name,id

Here index1 has suppose 15 ids, then index2 has 30 ids. Out of which 10 ids are common.

I am feeling difficulty here because "by name, device_id, interface" in this name is of index2 field and rest are of index1. So, I am feeling difficult.

0 Karma

darrenfuller
Contributor

This is not answerable without some more information about the data in these indexes 1 and 2. Can you post an event or two example of each (scrubbed is fine)

0 Karma

m4sucess
New Member

Hi, I have updated the query and added few information, let me know if you need more info.

Here index1 has suppose 15 ids, then index2 has 30 ids. Out of which 10 ids are common.

0 Karma

m4sucess
New Member

index="index1" sourcetype=show_command_output
| join Id [ search index="index2" sourcetype=software_data ]
| sort _time
| stats last(state) as state by name, device_id, interface
| where state != "UP"
| dedup name, device_id, interface

index1 has fields Id, device_id, interface
index2 has fields name, Id

Let me know if require more information

i am facing difficulty here "by name,device_id,interface" because name is field of index2 and device_id and interface are the fields of index1

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!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

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 ...