As we always say in this forum, illustration of raw input (in text format) is critical for the question to be answerable. Thank you for finally getting to data. My previous answer was based on KendallW's emulation. This latest illustration is not only different from that emulation, but also different from your initial screenshot. One fundamental difference is that this data includes multiple days potentially in the future. It seems that the input is from a prediction of sorts. This said, I also realized that JSON keys themselves can be utilized to simply solution if you are using Splunk 8.1 or later. Again, regex is NOT the correct tool for structured data. Here is the code you can try: | eval today = strftime(now(), "%F"), tomorrow = strftime(relative_time(now(), "+1d"), "%F")
| eval today = json_extract(_raw, "result.watt_hours_day." . today)
| eval tomorrow = json_extract(_raw, "result.watt_hours_day." . tomorrow) Here is an emulation for you to play with and compare with real data. Because your illustrated data is way in the past, I randomly pick 2019-06-26 as search time and establishes a "fake_now" field instead of using now() function. (As a result, "tomorrow" corresponds to 2019-06-27.) | makeresults
| eval _raw="{
\"result\": {
\"watts\": {
\"2019-06-22 05:15:00\": 17,
\"2019-06-22 05:30:00\": 22,
\"2019-06-22 05:45:00\": 27,
\"2019-06-29 20:15:00\": 14,
\"2019-06-29 20:30:00\": 11,
\"2019-06-29 20:45:00\": 7
},
\"watt_hours\": {
\"2019-06-22 05:15:00\": 0,
\"2019-06-22 05:30:00\": 6,
\"2019-06-22 05:45:00\": 12,
\"2019-06-29 20:15:00\": 2545,
\"2019-06-29 20:30:00\": 2548,
\"2019-06-29 20:45:00\": 2550
},
\"watt_hours_day\": {
\"2019-06-22\": 2626,
\"2019-06-23\": 2918,
\"2019-06-24\": 2526,
\"2019-06-25\": 2866,
\"2019-06-26\": 2892,
\"2019-06-27\": 1900,
\"2019-06-28\": 2199,
\"2019-06-29\": 2550
}
},
\"message\": {
\"type\": \"success\",
\"code\": 0,
\"text\": \"\"
}
}"
| spath
| eval fake_now = strptime("2019-06-26 18:15:06", "%F %T")
| eval today = strftime(fake_now, "%F"), tomorrow = strftime(relative_time(fake_now, "+1d"), "%F")
| eval today = json_extract(_raw, "result.watt_hours_day." . today)
| eval tomorrow = json_extract(_raw, "result.watt_hours_day." . tomorrow)
| fields result.watt_hours_day.2019-06-26 result.watt_hours_day.2019-06-27 today tomorrow Output is today tomorrow result.watt_hours_day.2019-06-26 result.watt_hours_day.2019-06-27 _raw 2892 1900 2892 1900 { "result": { "watts": { "2019-06-22 05:15:00": 17, "2019-06-22 05:30:00": 22, "2019-06-22 05:45:00": 27, "2019-06-29 20:15:00": 14, "2019-06-29 20:30:00": 11, "2019-06-29 20:45:00": 7 }, "watt_hours": { "2019-06-22 05:15:00": 0, "2019-06-22 05:30:00": 6, "2019-06-22 05:45:00": 12, "2019-06-29 20:15:00": 2545, "2019-06-29 20:30:00": 2548, "2019-06-29 20:45:00": 2550 }, "watt_hours_day": { "2019-06-22": 2626, "2019-06-23": 2918, "2019-06-24": 2526, "2019-06-25": 2866, "2019-06-26": 2892, "2019-06-27": 1900, "2019-06-28": 2199, "2019-06-29": 2550 } }, "message": { "type": "success", "code": 0, "text": "" } }
... View more