<?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: Noob Question - Parsing JSON in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694426#M236195</link>
    <description>&lt;P&gt;Just extract the content of "msg" into a new field, then apply spath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "msg=(?&amp;lt;msg&amp;gt;.+)"
| spath input=msg&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the output from your sample data&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;meteoHumidity&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;meteoRainlasthour&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteoTemp&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;meteoWindDirection&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteoWindSpeed&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteolunaPercent&lt;/TD&gt;&lt;TD width="1040.765625px" height="25px"&gt;msg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;64&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;17.9&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;SW&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;6.04&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;67.3&lt;/TD&gt;&lt;TD width="1040.765625px" height="25px"&gt;{"meteoTemp":17.9,"meteoHumidity":64,"meteoRainlasthour":0,"meteoWindSpeed":6.04,"meteoWindDirection":"SW","meteolunarPercent":67.3}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is an emulation for you to play with and compare with real data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "Fri Jul 26 15:24:46 BST 2024 name=mqtt_msg_received event_id= topic=meteobridge msg={\"meteoTemp\":17.9,\"meteoHumidity\":64,\"meteoRainlasthour\":0,\"meteoWindSpeed\":6.04,\"meteoWindDirection\":\"SW\",\"meteolunarPercent\":67.3}"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2024 21:33:01 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-07-26T21:33:01Z</dc:date>
    <item>
      <title>Noob Question - Parsing JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694417#M236194</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;complete Splunk beginner here, so sorry it this is a stupid question.&lt;/P&gt;&lt;P&gt;I'm trying to chart some data that I'm pulling from an MQTT broker. The Splunk&amp;nbsp; MQTT Modular Input app is doing its thing and data is arriving every 5 minutes.&lt;BR /&gt;&lt;BR /&gt;Using the most basic query&amp;nbsp; (&amp;nbsp; source="mqtt://MeteoMQTT"&amp;nbsp; ) gives these results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Fri Jul 26 15:24:46 BST 2024 name=mqtt_msg_received event_id= topic=meteobridge msg={"meteoTemp":17.9,"meteoHumidity":64,"meteoRainlasthour":0,"meteoWindSpeed":6.04,"meteoWindDirection":"SW","meteolunarPercent":67.3}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I really want to do though is to break out the values from the most recent data poll into separate "elements" that can then be added to a dashboard.&lt;/P&gt;&lt;P&gt;I tried using the spath command:&lt;/P&gt;&lt;P&gt;source="mqtt://MeteoMQTT" | spath output=meteoTemp path=meteoTemp&lt;/P&gt;&lt;P&gt;But that just returned the whole object again.&lt;BR /&gt;&lt;BR /&gt;So, how can i parse out the different values (meteoTemp, meteoHumidity, meteoRainlasthour, etc), so that i can add their most recent values as individual dashboard elements please?&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 14:46:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694417#M236194</guid>
      <dc:creator>ikoth</dc:creator>
      <dc:date>2024-07-26T14:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Noob Question - Parsing JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694426#M236195</link>
      <description>&lt;P&gt;Just extract the content of "msg" into a new field, then apply spath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "msg=(?&amp;lt;msg&amp;gt;.+)"
| spath input=msg&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the output from your sample data&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;meteoHumidity&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;meteoRainlasthour&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteoTemp&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;meteoWindDirection&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteoWindSpeed&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;meteolunaPercent&lt;/TD&gt;&lt;TD width="1040.765625px" height="25px"&gt;msg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;64&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;17.9&lt;/TD&gt;&lt;TD width="40px" height="25px"&gt;SW&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;6.04&lt;/TD&gt;&lt;TD width="42.90625px" height="25px"&gt;67.3&lt;/TD&gt;&lt;TD width="1040.765625px" height="25px"&gt;{"meteoTemp":17.9,"meteoHumidity":64,"meteoRainlasthour":0,"meteoWindSpeed":6.04,"meteoWindDirection":"SW","meteolunarPercent":67.3}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is an emulation for you to play with and compare with real data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "Fri Jul 26 15:24:46 BST 2024 name=mqtt_msg_received event_id= topic=meteobridge msg={\"meteoTemp\":17.9,\"meteoHumidity\":64,\"meteoRainlasthour\":0,\"meteoWindSpeed\":6.04,\"meteoWindDirection\":\"SW\",\"meteolunarPercent\":67.3}"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 21:33:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694426#M236195</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-26T21:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Noob Question - Parsing JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694457#M236212</link>
      <description>&lt;P&gt;Thanks for the quick reply. That has helped in that it's extracted the "msg data" section from the headers, but I'm still unsure of how to parse each individual value ("meteoTemp", or "meteolunarPercent" for example) into separate objects so they can represented by separate and different "widgets" on a dashboard. Sticking with those same two examples, I ultimately want to plot temperature on a line chart, but show lunarPercent as a single value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 19:10:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694457#M236212</guid>
      <dc:creator>ikoth</dc:creator>
      <dc:date>2024-07-26T19:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Noob Question - Parsing JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694462#M236214</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;headers, but I'm still unsure of how to parse each individual value ("meteoTemp", or "meteolunarPercent" for example) into separate objects so they can represented by separate and&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I am confused. &amp;nbsp;Have you viewed my sample output? &amp;nbsp;meteoTemp and&amp;nbsp;meteolunarPercent are extracted by spath, and tabulated in my example. &amp;nbsp;You can plot them however you want. &amp;nbsp;For example,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="mqtt://MeteoMQTT"
| rex "msg=(?&amp;lt;msg&amp;gt;.+)"
| spath input=msg
| timechart avg(meteoTemp) as avgMeteoTemp max(meteolunaPercent) as maxMeteolunaPercent&lt;/LI-CODE&gt;&lt;P&gt;If you do not get those fields, you need to play with my emulation and carefully compare with your raw data and post data that is representative of the actual data structure.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 21:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694462#M236214</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-26T21:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Noob Question - Parsing JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694476#M236219</link>
      <description>&lt;P&gt;Thank you! I'd forgotten / didn't realise I could chain terms together in searches. Your last example triggered the lightbulb.&lt;/P&gt;&lt;P&gt;Your help is much appreciated!"&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2024 09:40:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Noob-Question-Parsing-JSON/m-p/694476#M236219</guid>
      <dc:creator>ikoth</dc:creator>
      <dc:date>2024-07-27T09:40:45Z</dc:date>
    </item>
  </channel>
</rss>

