<?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: Parsing YAML file with Splunk in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38198#M763</link>
    <description>&lt;P&gt;Another option is to write your own search command.  I'm not familiar with YAML, but I goggled it and quickly found a python parser &lt;A href="http://pyyaml.org/wiki/PyYAML" rel="nofollow"&gt;PyYAML&lt;/A&gt; for it.&lt;/P&gt;

&lt;P&gt;I would suggest that you take a look at the search commands &lt;CODE&gt;xmlkv&lt;/CODE&gt; and &lt;CODE&gt;xpath&lt;/CODE&gt; that work with XML, and see if you could borrow the basic idea of those search commands and then write something similar for YAML using the PyYAML library.&lt;/P&gt;

&lt;P&gt;You can find many example search commands in the "search" app:  &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/bin/&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Specifically I think that &lt;CODE&gt;xpath.py&lt;/CODE&gt; is a good example of a search command that loads a python module and then uses that module to extract some field based on the structured data stored within the splunk event, and then adds a new field back into your splunk event, which can be then used by subsequent search commands.  Pretty simple, huh?  Seriously it's not very difficult to do, especially if you have any programming experience at all.  I've written a few search commands myself with very minimal effort.&lt;/P&gt;

&lt;P&gt;Besides the documentation, you may also find reviewing topics with the &lt;A href="http://answers.splunk.com/questions/tagged/custom-search-script" rel="nofollow"&gt;custom-search-script&lt;/A&gt; tag on this site to be helpful too.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Aug 2010 23:06:04 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2010-08-27T23:06:04Z</dc:date>
    <item>
      <title>Parsing YAML file with Splunk</title>
      <link>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38196#M761</link>
      <description>&lt;P&gt;I'm looking at using splunk as a central reporting tool to puppet, and was thinking of putting together "Puppet Dashboard" Like reporting tool. I selected my reports directory, and started indexing the YAML file, but they don't extract all that well.  Has anyone set up props / transforms to parse YAML files? &lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2010 02:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38196#M761</guid>
      <dc:creator>thartmann</dc:creator>
      <dc:date>2010-08-27T02:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing YAML file with Splunk</title>
      <link>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38197#M762</link>
      <description>&lt;P&gt;Yaml is a pretty flexible format, with complex relationships between data.  At search time, splunk is pretty much a key-value only beast -- although we have support for multiple values for a single key.&lt;/P&gt;

&lt;P&gt;Some users find it useful to flatten a complex data source to keyvalues before input time via a script or similar.  Other times it may be more convenient to create associations at search time.  &lt;/P&gt;

&lt;P&gt;I'd say it comes down to how sophisticated the file is and how much you want to pull out of it.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2010 07:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38197#M762</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2010-08-27T07:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing YAML file with Splunk</title>
      <link>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38198#M763</link>
      <description>&lt;P&gt;Another option is to write your own search command.  I'm not familiar with YAML, but I goggled it and quickly found a python parser &lt;A href="http://pyyaml.org/wiki/PyYAML" rel="nofollow"&gt;PyYAML&lt;/A&gt; for it.&lt;/P&gt;

&lt;P&gt;I would suggest that you take a look at the search commands &lt;CODE&gt;xmlkv&lt;/CODE&gt; and &lt;CODE&gt;xpath&lt;/CODE&gt; that work with XML, and see if you could borrow the basic idea of those search commands and then write something similar for YAML using the PyYAML library.&lt;/P&gt;

&lt;P&gt;You can find many example search commands in the "search" app:  &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/bin/&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Specifically I think that &lt;CODE&gt;xpath.py&lt;/CODE&gt; is a good example of a search command that loads a python module and then uses that module to extract some field based on the structured data stored within the splunk event, and then adds a new field back into your splunk event, which can be then used by subsequent search commands.  Pretty simple, huh?  Seriously it's not very difficult to do, especially if you have any programming experience at all.  I've written a few search commands myself with very minimal effort.&lt;/P&gt;

&lt;P&gt;Besides the documentation, you may also find reviewing topics with the &lt;A href="http://answers.splunk.com/questions/tagged/custom-search-script" rel="nofollow"&gt;custom-search-script&lt;/A&gt; tag on this site to be helpful too.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2010 23:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Parsing-YAML-file-with-Splunk/m-p/38198#M763</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-08-27T23:06:04Z</dc:date>
    </item>
  </channel>
</rss>

