Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Splunk 7 Essentials - Third Edition

You're reading from  Splunk 7 Essentials - Third Edition

Product type Book
Published in Mar 2018
Publisher Packt
ISBN-13 9781788839112
Pages 220 pages
Edition 3rd Edition
Languages
Authors (4):
J-P Contreras J-P Contreras
Profile icon J-P Contreras
Steven Koelpin Steven Koelpin
Erickson Delgado Erickson Delgado
Profile icon Erickson Delgado
Betsy Page Sigman Betsy Page Sigman
Profile icon Betsy Page Sigman
View More author details

Table of Contents (10) Chapters

Preface 1. Splunk – Getting Started 2. Bringing in Data 3. Search Processing Language 4. Reporting, Alerts, and Search Optimization 5. Dynamic Dashboarding 6. Data Models and Pivot 7. HTTP Event Collector 8. Best Practices and Advanced Queries 9. Taking Splunk to the Organization

Search command – rex

The rex or regular expression command is extremely useful when you need to extract a field during search time that has not already been extracted automatically. The rex command even works in multi-line events. The following sample command will get all versions of the Chrome browser that are defined in the highlighted user agent string part of the raw data. Let's say this is your raw data, and you need to get the highlighted value:

016-07-21 23:58:50:227303,96.32.0.0,GET,/destination/LAX/details,-,80, 
-,10.2.1.33,Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) 
AppleWebKit/537.36 (KHTML; like Gecko) Chrome/29.0.1547.76 
Safari/537.36,500,0,0,823,3053 

You can use this search command to get it:

SPL> index=main | rex field=http_user_agent 
     "Chrome/(?<Chrome_Version>.+?)?Safari" | top Chrome_Version 

The rex command extracted...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}