Have to create 12- month trend line and data I am getting it in JSON. Please check the enclosed screenshot, I could able to create the table.
| makeresults count=2
| eval time=split("2018-12-02#2019-03-24","#")
| mvexpand time
| eval _time=strptime(time,"%F")
| makecontinuous span=7d _time
| eval temp="480.0,480.0,480.0,470.0,470.0,470.0,460.0,460.0,460.0,460.0,470.0,510.0,510.0,510.0,520.0,530.0,530.0"
| streamstats current=f count
| eval y=mvindex(split(temp,","),count)
| eval x=strftime(_time,"%F")
| table y x
| eval count = 1
| stats list(*) as * by count
| rename x as "graph_data.ratings{}.x"
| rename y as "graph_data.ratings{}.y"
| fields - count
| rename COMMENT as "this is sample you provide"
| rename COMMENT as "from here, the logic"
| eval _time=strptime('graph_data.ratings{}.x',"%F")
| stats list(*) as * by _time
| streamstats current=f count
| eval rating=mvindex('graph_data.ratings{}.y',count)
| table _time rating
| rename COMMENT as "viz > Line Chart"
Hi, @chiraggl
I chose not to use mvexpand
.
Something like this should work for you, but you might need to play around with it a little to get the exact form you want (I didn't know if you had an _time field from these logs and if it correlated with the date stamp you had).
| baseSearch
| eval zip=mvzip('graph_data.ratings{}.y', 'graph_data.ratings{}x')
| mvexpand zip
| eval zip=split(zip, ",")
| eval ratings=mvindex(zip,0)
| eval time=mvindex(zip,1)
| eval _time=strptime(time, "%Y-%m-%d")
| timechart values(ratings) span=w
Essentially, zip each value pair together, expand them into their own rows, index out the values, create a _time field if it doesn't exist, then plug that into a timechart command. Hope this helps!