Dashboards & Visualizations

How to extract the field from raw logs

aditsss
Motivator

Hi, 

Below are my logs:

2020-10-14 01:59:59,889 INFO [-912674] o.a.n.w.s.AuthenticationFilter Attempting request for (<ppatt2><CN=abcdefg50450.phx.xp.com, OU=Middleware Utilities, L=Phoenix, ST=Arizona, C=US, SERIALNUMBER=188055, OID.1.3.6.1.4.1.311.60.2.1.2=New York, OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.2.5.4.15=Private Organization>) GET https://abcdefg50449.phx.xp.com:9091/api/flow/bulletin-board (source )

2020-10-14 02:00:32,995 INFO 67995] o.a.n.w.s.NiFiAuthenticationFilter Attempting request for (<vkravic><CN=abcdefg50450.phx.xp.com, OU=Middleware Utilities,  L=Phoenix, ST=Arizona, C=US, SERIALNUMBER=188055, OID.1.3.6.1.4.1.311.60.2.1.2=New York, OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.2.5.4.15=Private Organization>) POST https://abcdefg50450.phx.xp.com:9091/api/flowfile-queues/5aab3ee9-4bd1-1f35-9756-ed1248dbc67a/listin... (source)

I want two regex for two fields differently:

One mark in red as Request User and one mark in green as Request Type.

Can someone provide me regex's for both the fields.

Thanks in advance.

 

Labels (1)
0 Karma
1 Solution

to4kawa
Ultra Champion
| rex "\<(?<Request_User>\S+)\>"
| rex "(?<Request_Type>POST|GET|OPTIONS|HEAD|PUT)"

View solution in original post

to4kawa
Ultra Champion
| rex "\<(?<Request_User>\S+)\>"
| rex "(?<Request_Type>POST|GET|OPTIONS|HEAD|PUT)"

aditsss
Motivator

@to4kawa 

 

Thankyou so much for your  help.

0 Karma

to4kawa
Ultra Champion

 

index=_internal | head 1 | fields _raw | eval _raw="2020-10-14 01:59:59,889 INFO [-912674] o.a.n.w.s.AuthenticationFilter Attempting request for (<ppatt2><CN=abcdefg50450.phx.xp.com, OU=Middleware Utilities, L=Phoenix, ST=Arizona, C=US, SERIALNUMBER=188055, OID.1.3.6.1.4.1.311.60.2.1.2=New York, OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.2.5.4.15=Private Organization>) GET https://abcdefg50449.phx.xp.com:9091/api/flow/bulletin-board (source )"
| appendpipe [| eval _raw="2020-10-14 02:00:32,995 INFO 67995] o.a.n.w.s.NiFiAuthenticationFilter Attempting request for (<vkravic><CN=abcdefg50450.phx.xp.com, OU=Middleware Utilities,  L=Phoenix, ST=Arizona, C=US, SERIALNUMBER=188055, OID.1.3.6.1.4.1.311.60.2.1.2=New York, OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.2.5.4.15=Private Organization>) POST https://abcdefg50450.phx.xp.com:9091/api/flowfile-queues/5aab3ee9-4bd1-1f35-9756-ed1248dbc67a/listin... (source)"]
| rex "(?<time>\S+\s\S+) .*?\<(?<Request_User>\S+)\>.*(?<Request_Type>POST|GET|OPTIONS|HEAD|PUT)\s(?<url>\S+)"
| eval _time=strptime(time,"%F %T,%3Q")

 

how about this?

0 Karma

aditsss
Motivator

@to4kawa 

Can you provide separate regex for both.

 

It would be a great help.

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...