Splunk Search

Plotting Each element of a Json

rai4shambhavi
Explorer

so my log lines look something like this

<<METRIC-START>>{"A":332,"B":45,"C":67,"D":23,"E":234,"F":435,"G":43,"H":66,"I":32,"J":67,"K":21,"L":678,"M":45,"N":56}<<METRIC-END>>

It is in form of a Json and I am able to extract the fields along with time using this

| rex field=line "(?<=<<METRIC-START>>)(?<importMetrics>.*)(?=<<METRIC-END>>)"
| spath input=importMetrics

now I wish to plot A,B,C,D as timecharts, so I will have to give this command

| timechart span=1h
max(A) as A,
max(B) as B....till Z


So the whole query works fine but I wanted to know if there is anyshort way of doing it


| rex field=line "(?<=<<METRIC-START>>)(?<importMetrics>.*)(?=<<METRIC-END>>)"
| spath input=importMetrics
| timechart span=1h
max(A) as A,
max(B) as B....till Z


Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Given that you only appear to be interested in the fields in importMetrics, you can remove the other fields and then use wildcards

| rex field=line "(?<=<<METRIC-START>>)(?<importMetrics>.*)(?=<<METRIC-END>>)"
| spath input=importMetrics
| fields - line importMetrics
| timechart span=1h max(*) as *

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Given that you only appear to be interested in the fields in importMetrics, you can remove the other fields and then use wildcards

| rex field=line "(?<=<<METRIC-START>>)(?<importMetrics>.*)(?=<<METRIC-END>>)"
| spath input=importMetrics
| fields - line importMetrics
| timechart span=1h max(*) as *
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...