Dashboards & Visualizations

regex need help separating each row and creating fields

thaghost99
Path Finder

 

Hi i would like some help to extract each line of data into separate fields of Name, ID, Speed & duplex, state, mac address.

critical that "state" is its own field.

getting stuck and need help. thank you

Data below

 

name                    id    speed/duplex/state            mac address      
--------------------------------------------------------------------------------
ethernet1/3             66    1000/full/up                  b6:2c:23:e0:40:42
ethernet1/4             67    1000/full/up                 b6:2c:23:e0:40:43
ethernet1/5             68    10000/full/up                 b6:2c:23:e0:40:44
ethernet1/6             69    10000/full/up                 b6:2c:23:e0:40:45
ethernet1/7             70    10000/full/up                 b6:2c:23:e0:40:46
ethernet1/8             71    10000/full/up                 b6:2c:23:e0:40:47
ae1                     16    [n/a]/[n/a]/up                b6:2c:23:e0:40:10
ae2                     17    [n/a]/[n/a]/up                b6:2c:23:e0:40:11
ha1-a                   5     1000/full/up                  d1:f4:b3:c3:25:97
ha1-b                   7     1000/full/up                  d1:f4:b3:c3:25:96
vlan                    1     [n/a]/[n/a]/up                b6:2c:23:e0:40:01
loopback                3     [n/a]/[n/a]/up                b6:2c:23:e0:40:03
tunnel                  4     [n/a]/[n/a]/up                b6:2c:23:e0:40:04
hsci                    8     40000/full/up                 01:20:6c:1c:81:08 

 

any help will be appreciated. thanks, 

Labels (1)
Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Does it have to be regex?  I'm a big fan of them, but this problem looks like it's made for multikv.

---
If this reply helps you, Karma would be appreciated.

thaghost99
Path Finder

@richgalloway 

hi Rich are you able to do multikv help on this one?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Yes, I can help, but it's also in the manual.

| multikv forceheader=1
---
If this reply helps you, Karma would be appreciated.
0 Karma

thaghost99
Path Finder

no it does not have to be. its whatever works. 😃

0 Karma

thaghost99
Path Finder

hi @jotne it works great, just small favor. how do i stop it if it sees the below line 'aggregation groups'? with data below? cause its also capturing that part, but the rest is great. ty

name                    id    speed/duplex/state            mac address      
--------------------------------------------------------------------------------
ethernet1/3             66    1000/full/up                  b6:2c:23:e0:40:42
ethernet1/4             67    1000/full/up                 b6:2c:23:e0:40:43
ethernet1/5             68    10000/full/up                 b6:2c:23:e0:40:44
ethernet1/6             69    10000/full/up                 b6:2c:23:e0:40:45
ethernet1/7             70    10000/full/up                 b6:2c:23:e0:40:46
ethernet1/8             71    10000/full/up                 b6:2c:23:e0:40:47
ae1                     16    [n/a]/[n/a]/up                b6:2c:23:e0:40:10
ae2                     17    [n/a]/[n/a]/up                b6:2c:23:e0:40:11
ha1-a                   5     1000/full/up                  d1:f4:b3:c3:25:97
ha1-b                   7     1000/full/up                  d1:f4:b3:c3:25:96
vlan                    1     [n/a]/[n/a]/up                b6:2c:23:e0:40:01
loopback                3     [n/a]/[n/a]/up                b6:2c:23:e0:40:03
tunnel                  4     [n/a]/[n/a]/up                b6:2c:23:e0:40:04
hsci                    8     40000/full/up                 01:20:6c:1c:81:08


aggregation groups: 0
0 Karma

jotne
Builder

You could do that with a search command like this:

| search NOT "aggregation"

Or

| search id=*

0 Karma

jotne
Builder

Here you go:

(?<name>\S+)\s+(?<id>\d+)\s+(?<speed>[^\/]+)\/(?<duplex>[^\/]+)\/(?<state>\S+)\s+(?<mac>\S+)

https://regex101.com/r/99K6Do/1

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...

Event Series: Mastering AI Tokenomics and Splunk Agent Observability

Beyond the Black Box: Correlating AI Performance and Tokenomics with Splunk Agent Observability   As ...

span_metrics: The OpenTelemetry-Idiomatic Way to See Inside Your Services

You open a trace in Splunk Observability Cloud and everything looks fine. One root span, order-pipeline, with ...