<?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: How to join a header of a JSON file to the rest of the rows by one common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172553#M49454</link>
    <description>&lt;P&gt;This again produced an answer where only my min(build) results were displayed. But it would work if instead I had done: &lt;CODE&gt;index=main* | join build_num [search index=main* platform] | stats c(eval(status="FAIL") as "status" by build, area, project&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jan 2015 10:36:08 GMT</pubDate>
    <dc:creator>jalau9</dc:creator>
    <dc:date>2015-01-08T10:36:08Z</dc:date>
    <item>
      <title>How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172543#M49444</link>
      <description>&lt;P&gt;I have this JSON file which has a first (header) row that is different from the body. Number of fields in header row is less than in body. However, two fields are common in all rows. Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"project":"1.0","build":"20","milestone":"","platform":"","id":"A1"}
{"build":"20","area":"Area1","status":"Pass","owner":"Engr1","manager":"Mgr1","id":"A1"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to make 'project' from header to append to each of subsequent rows, then do 'stats count(status) by project, build, area'. Since build is common, I thought from other threads' advice to simply use it as the filter i.e. index=main build | stats count...&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;index=main* build | stats values(build) as one by project&lt;/CODE&gt; -&amp;gt; this can combine project with build, as it's the header row anyway&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;index=main* build | stats count(eval(status="FAIL") as "status" by build, area&lt;/CODE&gt; -&amp;gt; this is fine as it's all in the body anyway&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;index=main* build | stats count(eval(status="FAIL") as "status" by build, area, project&lt;/CODE&gt; -&amp;gt; this gives me zero results&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;If instead I do a join, &lt;CODE&gt;index=main* build | join id [search index=main* domain | dedup id] | stats count(eval(status="FAIL") as "status" by build, area, project&lt;/CODE&gt; -&amp;gt; this gets me correct data for the min(build) only. I have three distinct values of build but only the smallest is returned. How do I do a correct join?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jan 2015 07:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172543#M49444</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-04T07:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172544#M49445</link>
      <description>&lt;P&gt;Your naming in the join is not consistent with what you did before. However, I think your problems with the join are&lt;BR /&gt;&lt;BR /&gt;
(1) deduping the id eliminates all but one of the events.&lt;BR /&gt;&lt;BR /&gt;
(2) by default, the events from the main pipeline can join with only one event from the subsearch. You may need to use the the &lt;CODE&gt;max&lt;/CODE&gt; option of the &lt;CODE&gt;join&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;But I would do it differently. The following should work IF the header row always appears prior to the body rows&lt;/P&gt;

&lt;P&gt;NOTE: Edited to fix a problem with the original streamstats I wrote&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main* build 
| streamstats last(project) as lastproject current=f window=1 by build
| eval project = if(notnull(project),project,lastproject)
| where status=="FAIL"
| stats count as status by build, area, project
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jan 2015 06:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172544#M49445</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-05T06:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172545#M49446</link>
      <description>&lt;P&gt;move dedup command because you join with Id and in  you subsearch you dedup  eliminate other one of the events with same id.&lt;BR /&gt;
try this:&lt;/P&gt;

&lt;P&gt;index=main* build | join id [search index=lint* domain ] | stats c(eval(status="FAIL") as "status" by build, area, project&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 08:16:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172545#M49446</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-01-05T08:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172546#M49447</link>
      <description>&lt;P&gt;If you data contains just two rows for each build and id combination (common fields), one header and one body, like your example here, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main* build | stats values(*) as * by id,build | stats count(eval(mvcount(mvfilter(match(status,"FAIL"))))) as "status" by build, area, project
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jan 2015 05:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172546#M49447</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-01-06T05:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172547#M49448</link>
      <description>&lt;P&gt;Yes, you're right, I edited my question for consistency. When I tried this, I could not get a  statistics of stats count, but I could see the events filtered to those where status=="FAIL". However in these events, the project is blank as it wasn't appended. How can I append project to these events?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 02:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172547#M49448</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-07T02:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172548#M49449</link>
      <description>&lt;P&gt;My data is one header and one body (body has multiple rows), and id, build occurs in all rows, both header and body. When I tried this, every field of area was returned with "status"=1, even though their (original) status was not "FAIL". Why did that happen?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 02:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172548#M49449</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-07T02:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172549#M49450</link>
      <description>&lt;P&gt;Because this &lt;CODE&gt;stats&lt;/CODE&gt; command is wrong&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 18:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172549#M49450</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-07T18:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172550#M49451</link>
      <description>&lt;P&gt;I didn't do the streamstats command properly - I edited my answer above and hope this will fix it!&lt;BR /&gt;
Let me know if it does not work!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 18:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172550#M49451</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-07T18:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172551#M49452</link>
      <description>&lt;P&gt;I edited 'notnull' to 'isnotnull'. It's the same. I can see the events up to  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main* build 
 | streamstats last(project) as lastproject current=f window=1 by build
 | eval project = if(isnotnull(project),project,lastproject)
 | where status=="FAIL"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but when I view the search results at this query level, project field is empty. When I append &lt;CODE&gt;| stats count as status by build, area, project&lt;/CODE&gt; to the end, no results come out unless I remove project.&lt;/P&gt;

&lt;P&gt;Another thing I don't understand about this query is that when I do  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main* build 
     | streamstats last(project) as lastproject current=f window=1 by build | table lastproject
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;, I get no results. Why is that?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 07:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172551#M49452</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-08T07:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172552#M49453</link>
      <description>&lt;P&gt;After much hair-tearing, reading Splunk blogs, documentation on stats, streamstats, etc, I found this query to work: &lt;CODE&gt;index=main* | join build [search index=main* platform] | where status="FAIL" | stats count(status) by build, project, area&lt;/CODE&gt;&lt;BR /&gt;
I find it so little different from my 4th approach, how did it not work previously?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 10:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172552#M49453</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-08T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172553#M49454</link>
      <description>&lt;P&gt;This again produced an answer where only my min(build) results were displayed. But it would work if instead I had done: &lt;CODE&gt;index=main* | join build_num [search index=main* platform] | stats c(eval(status="FAIL") as "status" by build, area, project&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 10:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172553#M49454</guid>
      <dc:creator>jalau9</dc:creator>
      <dc:date>2015-01-08T10:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172554#M49455</link>
      <description>&lt;P&gt;Crud, something is still not working to propagate the project field across the events. The reason that you get nothing with stats command is that the project does not exist in all events. lastproject should be there, but since it isn't, then something is still probably wrong with the streamstats...&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 16:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172554#M49455</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-08T16:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to join a header of a JSON file to the rest of the rows by one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172555#M49456</link>
      <description>&lt;P&gt;You didn't use dedup is the biggest thing.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 16:04:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-a-header-of-a-JSON-file-to-the-rest-of-the-rows-by/m-p/172555#M49456</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-08T16:04:30Z</dc:date>
    </item>
  </channel>
</rss>

