Splunk Search

How to evaluate the following string as a fields

Hema_Nithya
Explorer

Hi , 
I have two servers with plugin details . I want to evaluate a column as Package_installed and Package_shouldbe based on the hostname in separate column .

server2 has multiple packages I want separate row and column for each package_shouldbe and package_installed and hostname field should be same .

hostnamePlugins
server1Plugin Output:
Remote package installed : gnutls-3.6.16-5.el8_6
Should be                : gnutls-3.6.16-6.el8_7

NOTE: The vulnerability information above was derived by checking the
package versions of the affected packages from this advisory. This
scan is unable to rely on Red Hat's own security checks, which
consider channels and products in their vulnerability determinations.
server2Plugin Output:
Remote package installed : httpd-2.4.6-98.el7_9.6
Should be                : httpd-2.4.6-98.el7_9.7

Remote package installed : httpd-tools-2.4.6-98.el7_9.6
Should be                : httpd-tools-2.4.6-98.el7_9.7

Remote package installed : mod_session-2.4.6-98.el7_9.6
Should be                : mod_session-2.4.6-98.el7_9.7

NOTE: The vulnerability information above was derived by checking the
package versions of the affected packages from this advisory. This
scan is unable to rely on Red Hat's own security checks, which
consider channels and products in their vulnerability determinations.
Labels (5)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try this:

<<your current search>>
``` Extract installed packages ```
| rex max_match=0 field=Plugins "package installed\s*:\s*(?<installed>\S+)"
``` Extract "should be" names ```
| rex max_match=0 field=Plugins "Should be\s*:\s*(?<shouldBe>\S+)"
``` Pair installed with shouldBe ```
| eval packages=mvzip(installed, shouldBe, "#")
``` Give each pair its own event ```
| mvexpand packages
``` Break pairs apart ```
| eval packages=split(packages, "#")
| eval installed=mvindex(packages, 0), shouldBe=mvindex(packages, 1)
| table hostname installed shouldBe
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

Hema_Nithya
Explorer

I have another issue in comparing and want to compare should_be with server_installed_package . Sometime package installed is higher after patching . Example given below for git , if the number 2 < 3 , it should mark as completed , else it should check for the next digit if it is 2. and it should check for another number . 

 

CIInstalled shouldbeserver_installed_package 
server1git-2.31.1-3.el8_7git-2.39.3-1.el8_8git-3.40.3-1.el8_8Not complete
0 Karma

richgalloway
SplunkTrust
SplunkTrust

A new issue should be in a new question.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this:

<<your current search>>
``` Extract installed packages ```
| rex max_match=0 field=Plugins "package installed\s*:\s*(?<installed>\S+)"
``` Extract "should be" names ```
| rex max_match=0 field=Plugins "Should be\s*:\s*(?<shouldBe>\S+)"
``` Pair installed with shouldBe ```
| eval packages=mvzip(installed, shouldBe, "#")
``` Give each pair its own event ```
| mvexpand packages
``` Break pairs apart ```
| eval packages=split(packages, "#")
| eval installed=mvindex(packages, 0), shouldBe=mvindex(packages, 1)
| table hostname installed shouldBe
---
If this reply helps you, Karma would be appreciated.
0 Karma

Hema_Nithya
Explorer

It worked , thanks a lot

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!

Automated Threat Analysis: Available in ES Premier

Automated Threat Analysis: Centralize and Accelerate Phishing Investigations in Splunk Enterprise ...

What’s New in Splunk AI: Volume 02

Welcome to the second edition of “What’s New in Splunk AI” where we look at the latest and greatest updates, ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...