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!

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...

Splunk Developers: Construct Your Future at the .conf26 Builder Bar

Calling all Splunk architects, platform admins, and app developers: the site is open, and the blueprints are ...

Quick connection discovery mode for forwarders

When a Splunk forwarder loses connectivity to its indexers, it does not always reconnect immediately. In many ...