Splunk Search

Query that checks if field values have changed to exclude events

Splunkie
Explorer

Hi Friends,

I am working a query that checks if the value of a field has changed to a state of resolved to exclude it from the results of active cases.

The field I am trying to use to check if a case has been resold is the status field.  I need help with a query that looks at all cases with the status of Active and removes cases whose status has now changed to Resolved from the results.

Thank you.

Labels (1)
Tags (1)
0 Karma

splunkmarroko
Engager

try this:
base search   ``` index=xyz sourcetype=abc```
| where status!=resolved  ```if you already have the "resolved field", if not consider extracting that field.

0 Karma

Splunkie
Explorer

Thanks @splunkmarroko,

Thanks. I tried that, however going about it that way returns the initial events with an "Active" status and does not take into consideration that the status has changed from "Active" to "Resolved".

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @Splunkie 

To exclude cases that have transitioned to "Resolved" and only show currently active cases, find the latest status per case and filter where that status is "Active".

| your_search_here
| stats latest(status) as latest_status by case_id
| where latest_status="Active"

stats latest(status) by case_id groups events by case and finds the most recent status update per case

where latest_status="Active" filters to only cases whose latest status is still "Active"

This effectively excludes cases that have been resolved or closed later

Replace case_id with your actual case identifier field

🌟Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

Splunkie
Explorer

Thanks @livehybrid,

This works but returns inaccurate results when the search is run using the real time search time filter. This is an example of what I have;

| base_search here

| stats latest(status) as latest_status by incidentId
| where latest_status!="Resolved"
| stats count as total

 

The output is to count the number of active incidents to be displayed on a dashboard. Any pointer or tips on how to better achieve this will be appreciated.

Cheers.

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...