Splunk Search

trouble with regex

nicolay_koecher
Explorer

Hello
I have sone trouble with regex
I want build a table or a chart wirh the following content:

I started with this regex command:
^(?:[^ \n]* ){5}(?P<prn_upd>\w+\s+\w+)
2015-04-25 15:07:17.273 Total number of printers deleted: 2
but this shows only the text printers deleted not the quantity - can anybody help me in this?

lastly the table should look like this:

Date Printer created quantity
date Printer deletet quantity
date printers obsoleted
date printers updated
date errors

this is the origin logfile:
2015-04-25 11:07:30.008 Total number of printers created: 0
2015-04-25 11:07:30.008 Total number of printers deleted: 2
2015-04-25 11:07:30.008 Total number of printers obsoleted: 0
2015-04-25 11:07:30.008 Total number of printers updated: 0
2015-04-25 11:07:30.008 Total number of printers with errors: 0

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this. The format will be a little different from what you asked for, but it should get you started.

... | rex "printers (?P<prn_upd>[^:]*):\s*(?P<quantity>\d+)" | stats sum(quantity) as Sum by _time prn_upd | table _time prn_upd Sum`
---
If this reply helps you, Karma would be appreciated.
0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

Here is a quick REGEX: https://regex101.com/r/aK7iQ7/5 It could probably be improved.

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!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...