Splunk Search

How to generate 2 lines of events based on a condition?

David_B
Loves-to-Learn

Hello, 

I have a couple splunk columns that looks as follows:

server:incident:incident#:severity severity

 

this object is then fed to another system which separates and generates incidents.

Server: hostname

incident: category of incident

incident#: the incident number

sererity: Critical/Warning/Clear

Example:

serverA:zabbix:123456:Warning Warning
serverA:zabbix:123456:Critical Critical 

 

The objective is that it generates uniqueness of the incident (if warning, then create a ticket, if Critical then call out)

All works well when with the separate of Critical and Warning alerts, however when one clear is generated, I need to generate two records to look as follows:

serverA:zabbix:123456:Warning Clear
serverA:zabbix:123456:Critical Clear 

 

This way, the object that has been sent will get the clear.

Is there a way to achieve this?

Thanks

David

Labels (1)
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @David_B,

you have to divide fields from column1 using a regex, something like this:

<your_search>
| rex field=column1 "^([^:]*:){3}(?<severity>\w*)"
| eval column2=if(column2="clear",severity,column2
| table column1 column2

you can test the regex at https://regex101.com/r/KUTS3I/1

Ciao.

Giuseppe

0 Karma

David_B
Loves-to-Learn

Hi @gcusello 

Thanks for your reply.

Instead of having the outputs as 2 columns, I need to have two rows generated 

For example an serverA has generated an incident  that is a warning (say disk space)

serverA:zabbix:123456:WarningWarning

the tool picks up the event and generates a ticket.  Lets say nobody has done anything with it.

That disk has now reached critical and escalates the incident. Splunk picks up the event

serverA:zabbix:123456:CriticalCritical 

because column1 is unique, the tool picks up the event and calls out the team.  The team then clear the space.

Splunk picks up the event as:

serverA:zabbix:123456:ClearClear

However, that is not match the column1 above. What I need is that when a clear is generated, Splunk generates 2 "fake" records that would look as follows:

serverA:zabbix:123456:WarningClear
serverA:zabbix:123456:CriticalClear

So that Column1 matches the initial columns above and the tool will pick up 2 events and clear both records that were generated.

Thanks,

David

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Assuming your fields are called column_1 and column_2, you could try something like this

| rex field=column_1 "(?<Server>[^:]+):(?<Incident>[^:]+):(?<IncidentNumber>[^:]+):(?<Severity>.*)"
| eventstats values(Severity) as AllSeverities by Server Incident IncidentNumber
| eval AllSeverities=if(Severity="Clear",AllSeverities,Severity)
| mvexpand AllSeverities
| eval column_1=Server.":".Incident.":".IncidentNumber.":".AllSeverities
| fields column_1 column_2
| dedup column_1 column_2
0 Karma

David_B
Loves-to-Learn

Hi @ITWhisperer ,

Thanks for your reply.  I have taken your code and modified it with the correct columns

| table tool host object_class object severity parameter value message support_group
| rex field=object "^([^:]*:){3}(?<severity>\w*)"
| eventstats values(severity) as AllSeverities by host "OEM_ISSUE" value
| eval AllSeverities=if(severity="Clear",AllSeverities,severity)
| mvexpand AllSeverities
| eval object=host.":OEM_ISSUE:".value.":".AllSeverities
| fields object severity
| dedup object severity

I am getting 2 records for the first clear however instead of the 2 rows showing as

serverA:zabbix:123456:WarningClear
serverA:zabbix:123456:CriticalClear 

I am getting

serverA:zabbix:123456:ClearClear
serverA:zabbix:123456:CriticalCritical 

after the first clear severity, I am getting only one record as (different incident id and server for example)

serverB:zabbix:123457:ClearClear

Any help is greatly appreciated!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You are re-using field name severity - you also already seem to have values extracted to fields. What do you have for this

| table tool host object_class object severity parameter value message support_group
0 Karma

David_B
Loves-to-Learn

Hi @ITWhisperer 

Not sure what you mean by re-using field name severity as Column_1 is the object and column_2 is the severity

Here is what some output looks like for 

| table tool host object_class object severity parameter value message support_group
Ignore the first column (I put that in for explanation purposes)
 toolhostobject_classobjectseverityparametervaluemessagesupport_group
1ToolServerAOS_INCIDENTServerA.zabbix:1380217:WarningWARNINGOS_ISSUE_NUM1380217ServerA - Disk space is at 80%OS  Support
2ToolServerAOS_INCIDENTServerA.zabbix:1380217:CriticalCRITICALOS_ISSUE_NUM1380217CALL OUT - ServerA - Disk Space is at 90%OS Support
3ToolServerAOS_INCIDENTServerA.zabbix:1380217:ClearCLEAROS_ISSUE_NUM1380217ServerA -Disk Space ClearOS  Support
          
4ToolServerAOS_INCIDENTServerA.zabbix:1380217:WarningCLEAROS_ISSUE_NUM1380217ServerA -Disk Space ClearOS  Support
5ToolServerAOS_INCIDENTServerA.zabbix:1380217:CriticalCLEAROS_ISSUE_NUM1380217CALL OUT - ServerA - Disk Space ClearOS Support

What I am currently getting is 1,2,3, however what I need is 1 and 2, and when I get a result like 3, change it be 4 and 5

Hope that makes sense 🙂

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...