<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a Line-Chart from an Array within a Single Event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362299#M107029</link>
    <description>&lt;P&gt;Thanks for your suggestion - it follows the same concept as niketnilays' suggestion, as I have problems in seeing  the benefit of splitting my event up to smaller ones... But what do mean with "how the even looks"? I copied (and slightly edited) the event straight from the search app (highlighted)... Do you mean the raw event text? &lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2017 21:53:31 GMT</pubDate>
    <dc:creator>hbrandt84</dc:creator>
    <dc:date>2017-05-04T21:53:31Z</dc:date>
    <item>
      <title>Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362294#M107024</link>
      <description>&lt;P&gt;Hi everybody,&lt;BR /&gt;
I'm trying wrap my head around chart visualizations with Splunk.&lt;BR /&gt;
As a Start i'm working with machine data that represents power consumption of a motor over time during one integral action.&lt;BR /&gt;
the resulting JSON event looks kinda like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   [-] 
     motor_name:     prod_50cal 
     client:         defense_arc    
     start-event:    true
     tech_data: {   [-] 
         power_curve_real:  [   [-] 
         4.01   
         3.08
         3.32   
         ...
         4.17   
         5.69
         6.45
         5.85
        ]   
         direction:  mount  
         power_curve_limit: [   [+] 
        ]   
    }   
     message_type:   mounting_start
     timestamp:  2017-04-11 23:49:34    
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The "..." cuts the content here for visual reasons, as there are 100 values in each "power_curve_real: []".&lt;BR /&gt;
Every example and Discussion about visualization in Splunk dashboards i've seen concern using one value from every event und unify them in a chart.&lt;BR /&gt;
In my case i try to transform every event into a single line of a linechart. Plus, i want to show a "trendline" - an average of all shown lines.&lt;BR /&gt;
My Main logical Problem is the definition of the X-Axis and Y-Axis...&lt;BR /&gt;
My power-data entries are obviously my values for the Y-Axis, but the X-Axis is still undefined, as it needs to have the array index "1,2,3 ... 98,99,100" as discription. (but this index does not exist as literals within the event...) &lt;/P&gt;

&lt;P&gt;I'm totally clueless as i have not found any commands that are suitable for this kind of event.&lt;BR /&gt;
I'm thankful and open for any suggestions...  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362294#M107024</guid>
      <dc:creator>hbrandt84</dc:creator>
      <dc:date>2020-09-29T13:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362295#M107025</link>
      <description>&lt;P&gt;hello there, &lt;BR /&gt;
can you kindly show how the even looks in Splunk?&lt;BR /&gt;
if its a mutlivalue field that contains 100 numeric values, you can manipulate it as shown here: &lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.3/Search/Parsemultivaluefields"&gt;https://docs.splunk.com/Documentation/Splunk/6.5.3/Search/Parsemultivaluefields&lt;/A&gt;&lt;BR /&gt;
hope its a start&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 03:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362295#M107025</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-05-04T03:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362296#M107026</link>
      <description>&lt;P&gt;The command you are looking for is &lt;CODE&gt;spath&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;After you extract the array of values from the JSON into a multivalue field with that command, you are going to want to use &lt;CODE&gt;mvexpand&lt;/CODE&gt; to turn each individual value of that field into an individual record.  &lt;/P&gt;

&lt;P&gt;What you need will be pretty close to what I did in the answer for this one, and what I posted there was run-anywhere code.  My answer hasn't been approved yet, but when it appears you can play with it line by line and see what each command does. Modifying it for your own needs should not be too difficult.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/525678/parse-json-series-data-into-a-chart.html"&gt;https://answers.splunk.com/answers/525678/parse-json-series-data-into-a-chart.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You will have to determine whatever makes sense to do with the _time of each record, but to start your viz, just use a command something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(after you've splilt up the records)
| streamstats count as mycount
| eval _time =now()+mycount  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will give each one, in order, a different time by 1 second, which is enough so that everything doesn't all happen at once.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;  &lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 03:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362296#M107026</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-04T03:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362297#M107027</link>
      <description>&lt;P&gt;If you extract &lt;STRONG&gt;power_curve_real&lt;/STRONG&gt; as multivalued field using the spath command, then you can use &lt;STRONG&gt;mvexpand&lt;/STRONG&gt; to create single event for each of the values of power_curve_real.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362297#M107027</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T13:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362298#M107028</link>
      <description>&lt;P&gt;Yeah, I had already seen that command and I got the concept of dividing a single event into individual events. But I still don't see the benefit over multiple events. Is this nescessary for the visualisation to have each X/Y value pair in a seperate event?&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 21:50:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362298#M107028</guid>
      <dc:creator>hbrandt84</dc:creator>
      <dc:date>2017-05-04T21:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362299#M107029</link>
      <description>&lt;P&gt;Thanks for your suggestion - it follows the same concept as niketnilays' suggestion, as I have problems in seeing  the benefit of splitting my event up to smaller ones... But what do mean with "how the even looks"? I copied (and slightly edited) the event straight from the search app (highlighted)... Do you mean the raw event text? &lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 21:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362299#M107029</guid>
      <dc:creator>hbrandt84</dc:creator>
      <dc:date>2017-05-04T21:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362300#M107030</link>
      <description>&lt;P&gt;Okay, thanks for your response. I was especially looking for spl ideas that create X/Y axis value parts - and the mvzip approach might do the trick! Tomorrow I will try to apply this to my approach.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 22:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362300#M107030</guid>
      <dc:creator>hbrandt84</dc:creator>
      <dc:date>2017-05-04T22:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Line-Chart from an Array within a Single Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362301#M107031</link>
      <description>&lt;P&gt;Oh, here's another useful item:  mvrange(A,B,C) where A, B, and C are numbers or variables that equate to numbers, creates an mv field that starts at A and proceeds by step C until it is greater than or equal to B.  C(defaults to 1.&lt;/P&gt;

&lt;P&gt;For example, &lt;CODE&gt;mvrange(1,11,2)&lt;/CODE&gt; is equivalent to &lt;CODE&gt;mvappend(1,3,5,7,9)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So, for example, assuming that PowerCurveReal and PowerCurveLimit always have the same number of readings, you could say...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval readings=mvrange(1,mvcount (PowerCurveReal))
| eval readings=mvzip(readings,mvzip(PowerCurveReal,PowerCurveLimit,"!!!!"),"!!!!")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and then you would have them all zipped together with a delimiter that won't ever appear in the data, in a way you can turn each composite reading into a single record.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 23:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-Line-Chart-from-an-Array-within-a-Single-Event/m-p/362301#M107031</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-04T23:53:49Z</dc:date>
    </item>
  </channel>
</rss>

