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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...