Please use raw text to post sample JSON events, not screenshot and not Splunk's contracted pretty format. Do you mean the value{0} correspond to dsnames{0}, and value{1} to dsnames{1}? This is about...
See more...
Please use raw text to post sample JSON events, not screenshot and not Splunk's contracted pretty format. Do you mean the value{0} correspond to dsnames{0}, and value{1} to dsnames{1}? This is about as wasteful as JSON data design goes. If you have influence on developers who wrote these logs, implore them to change the structure to array of hashes instead of hash of arrays. Like this: {"whatever":
[
{"dsname":"read", "dstype":"typefoo", "value": 123},
{"dsname":"write", "dstype":"typebar", "value": 456}
]
} Before that happens, you can contain the damage from your developers' crimes with some reconstruction. Traditionally, this is done with string concatenation; and usually, you need mvmap to handle indeterminant number or large number of array elements. In this case, there are only two semantic values so I'll not be bothered with mvmap. I will also use structured JSON instead of string concatenation. (JSON function was introduced in Splunk 8.0.) | eval data = mvappend(json_object("dsname", mvindex('dsnames{}', 0), "value", mvindex('values{}', 0)),
json_object("dsname", mvindex('dsnames{}', 1), "value", mvindex('values{}', 1)))
| mvexpand data
| spath input=data
| stats min(value) as min max(value) as max avg(value) as avg by dsname
| eval min=round(min, 2)
| eval max=round(max, 2)
| eval avg=round(avg, 2) Here is some mock data that I use to test the above _raw dsnames{} values{} {"dsnames": ["read", "write"], "values": [123, 234]} read write 123 234 {"dsnames": ["read", "write"], "values": [456, 567]} read write 456 567 This is an emulation to get the above | makeresults
| eval data=mvappend("{\"dsnames\": [\"read\", \"write\"], \"values\": [123, 234]}", "{\"dsnames\": [\"read\", \"write\"], \"values\": [456, 567]}")
| mvexpand data
| rename data as _raw
| spath
``` data emulation above ``` You can play with this and compare with real data. This mock data gives dsname min max avg read 123.00 456.00 289.50 write 234.00 567.00 400.50