Splunk Search

rex to extract a field

Mohsin123
Path Finder

How do I extract connection attempt failed from the below log

2017-12-20T07:51:05.847Z I REPL [ReplicationExecutor] Error in heartbeat request to 10.78.33.13:8191; Location18915 Failed attempt to connect to 10.78.33.13:8191; couldn't connect to server 10.78.33.13:8191 (10.78.33.13), connection attempt failed

Tags (1)
0 Karma

nickhills
Ultra Champion

try this:
(?<err_message>Error.+;).+,(?<err_reason>.+)

It will extract two fields - err_message and err_reason

If my comment helps, please give it a thumbs up!
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi shraddhamuduli,
which information do you want to extract?
if you want to extract the message "connection attempt failed", it's easy

| rex ".*\),(?<my_field>.*)$"

if you want to extract other fields (e.g. server and port failed), it's

| rex ".*server\s(?<ip>\d+\.\d+\.\d+\.\d+):(?<port>\d+)"

Bye.
Giuseppe

harsmarvania57
Ultra Champion

Hi,

Can you please try <yourBasesearch> | rex ".*,\s(?<status>.*)", this will extract connection attempt failed in new field called status

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...