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
Get Updates on the Splunk Community!

Celebrating Fast Lane: 2025 Authorized Learning Partner of the Year

At .conf25, Splunk proudly recognized Fast Lane as the 2025 Authorized Learning Partner of the Year. This ...

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...