Splunk Search

how can i set a variables to each jsonarray object?

ktaeil
Engager

_Raw json format is below
{
"test-03": {
"field1": 97869,
"field2": 179771,
"field3": "test-03",
"traffics": 1070140210
},
"test-08": {
"field1": 53094,
"field2": 103840,
"field3": "test-08",
"traffics": 998807234
},
"test-09": {
"field1": 145655,
"field2": 250518,
"field3": "test-09",
"traffics": 2212423288
},
"test-10": {
"field1": 83663,
"field2": 151029,
"field3": "test-10",
"traffics": 762554139
},
"k": 63314
}

when i use  timechart avg(test*.traffics) , it works 

 but number was so huge, so i tried to change |eval test*.traffics=round(test*.traffics/1024,2) but it didnt work.

can anybody help it please

Labels (2)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

You cannot use wildcard group in eval.  Use foreach to iterate.

| foreach test-*.traffics
    [eval <<FIELD>> = round('<<FIELD>>' / 1024, 2)]

View solution in original post

Tags (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You cannot use wildcard group in eval.  Use foreach to iterate.

| foreach test-*.traffics
    [eval <<FIELD>> = round('<<FIELD>>' / 1024, 2)]
Tags (1)
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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...