<?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: Extracting simple array of strings in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266172#M16784</link>
    <description>&lt;P&gt;Odd - what happens when you run this in an empty search bar?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval foo = "types=[\"A\",\"B\",\"C\"] types=[\"B\",\"C\"]" | makemv foo | mvexpand foo | rename foo as _raw | extract | eval types = replace(types, "(^\[\")|(\"\]$)", "")| makemv types delim="\",\"" | stats count by types
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Mar 2016 22:58:21 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2016-03-30T22:58:21Z</dc:date>
    <item>
      <title>Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266169#M16781</link>
      <description>&lt;P&gt;I have a simple entry in my logs like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;types=["A","B","C"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are several entries like that throughout the logs. Another one could look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;types=["B","C"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to extract the values from this array of strings and create a bar chart out of the occurrences of each type? So if splunk only saw the above 2 long entries it would make a bar chart with&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt; "# of occurrences" on the y-axis&lt;/LI&gt;
&lt;LI&gt;"Types" on the x-axis&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;And it would show 1 for type A, 2 for type B and C.&lt;/P&gt;

&lt;P&gt;What would be the search criterion?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 22:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266169#M16781</guid>
      <dc:creator>sankarms</dc:creator>
      <dc:date>2016-03-30T22:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266170#M16782</link>
      <description>&lt;P&gt;You could cheat by going through &lt;CODE&gt;spath&lt;/CODE&gt; parsing JSON:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval types = "{\"types\": " + types + "}" | spath input=types | rename types{} as types | stats count by types
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, a bit of regexing around:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval types = replace(types, "(^\[\")|(\"\]$)", "")| makemv types delim="\",\"" | stats count by types
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2016 22:31:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266170#M16782</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-03-30T22:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266171#M16783</link>
      <description>&lt;P&gt;this doesn't extract the individual types separately. This gives back the whole list like so&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;["A","B","C"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and counts it as 1 object.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 22:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266171#M16783</guid>
      <dc:creator>sankarms</dc:creator>
      <dc:date>2016-03-30T22:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266172#M16784</link>
      <description>&lt;P&gt;Odd - what happens when you run this in an empty search bar?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval foo = "types=[\"A\",\"B\",\"C\"] types=[\"B\",\"C\"]" | makemv foo | mvexpand foo | rename foo as _raw | extract | eval types = replace(types, "(^\[\")|(\"\]$)", "")| makemv types delim="\",\"" | stats count by types
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2016 22:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266172#M16784</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-03-30T22:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266173#M16785</link>
      <description>&lt;P&gt;Sorry I'm an absolute idiot. I messed up something from your original command. It works perfectly fine now. Thank you. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 23:02:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266173#M16785</guid>
      <dc:creator>sankarms</dc:creator>
      <dc:date>2016-03-30T23:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting simple array of strings</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266174#M16786</link>
      <description>&lt;P&gt;What does the statistics table look like, and what visualization are you using?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 23:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Extracting-simple-array-of-strings/m-p/266174#M16786</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-03-30T23:24:27Z</dc:date>
    </item>
  </channel>
</rss>

