Dashboards & Visualizations

regex

SN1
Explorer

 hi , I want to extract from  this date

12/11/2024

result should be 12/2024

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @SN1 ,

if this is a field (your_field), the easiest way it to use the eval functions, not a regex:

| eval date=strftime(strptime(your_field,"%m/%d/%Y"),"%m/%Y")

Ciao.

Giuseppe

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Apart from what @gcusello says, rex will only extract contiguous characters into a field, so what you are asking for is not possible in a single rex command.

gcusello
SplunkTrust
SplunkTrust

Hi @SN1 ,

if this is a field (your_field), the easiest way it to use the eval functions, not a regex:

| eval date=strftime(strptime(your_field,"%m/%d/%Y"),"%m/%Y")

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Message Parsing in SOCK

Introduction This blog post is part of an ongoing series on SOCK enablement. In this blog post, I will write ...

Exploring the OpenTelemetry Collector’s Kubernetes annotation-based discovery

We’ve already explored a few topics around observability in a Kubernetes environment -- Common Failures in a ...

Use ‘em or lose ‘em | Splunk training units do expire

Whether it’s hummus, a ham sandwich, or a human, almost everything in this world has an expiration date. And, ...