Splunk Search

How to extract, convert and show data

Sentira
Explorer

I have following data and :

......
2021-06-18 21:05:45.037 +02:00 [Information] Status=[1111111111111111111111111111111111111111111111111111111111111111]"
2021-06-18 21:05:45.037 +02:00 [Information] Status=[1111111111111111111111111111111111111111111111111111111111111111]"
2021-06-18 21:05:45.037 +02:00 [Information] Status=[1111111111111111111111111111111111111111111111111111111111111111]"
.....


I need to extract the Status field from log data and each character of value belongs to one Item. 
Example: 1 is status OK for Item_1, second 1 is status OK for Item_2, etc. * (Total Items=64)
Finally I want to extract the raw data and convert to Status and link to a Item:

_timeItemsStatus
2021-06-18 21:05:45.037Item_1Ok
2021-06-18 21:05:46.037Item_1Not Ok
2021-06-18 21:05:47.037Item_2Ok
2021-06-18 21:05:49.037Item_n....

....

I have tried the following Script without success:


source="C:\\Logs\\*" host="392" index="Items"
| eval length=len(Status)
| where length > 60
| eval Item_1=substr(Status , 2 ,1), Item_2=substr(Status , 3 ,1), Item_3=substr(Status , 4 ,1),Item_4=substr(Status , 5 ,1),
|eval fieldnames = ""
|foreach Item_* [ eval "<<FIELD>>" = case(<<FIELD>> == 0,"Not Ok",<<FIELD>>== 1, "Ok",<<FIELD>>== 2 ,"Not Known")| eval test=<<FIELD>>]
|foreach Dump_Chute* [ eval fieldnames= fieldnames."<<FIELD>>;"]
|eval fieldnames = split(fieldnames, ";")
|table fieldnames test _time

 

Labels (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| makeresults 
| eval _raw="2021-06-18 21:05:45.037 +02:00 [Information] Status=[1111111111111111111111111111111111111111111111111111111111111111]"


| rex "Status=(?<Status>.*)"
| eval Status=split(trim(Status,"[]"),"")
| streamstats count as row 
| mvexpand Status
| streamstats count as item by row
| eval item="item_".item
| eval Status=case(Status==0,"Not OK",Status==1,"OK",Status=2,"Not Known")
0 Karma
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!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...