<?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: Need to make a new field with values of new made fields from two indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312676#M93623</link>
    <description>&lt;P&gt;Thanks for your suggestion, but it wil not work because of the following:&lt;/P&gt;

&lt;P&gt;Archief and DatumWachtkamer are also fields made with eval with time contents from two existing fields that are in two indexes.&lt;/P&gt;

&lt;P&gt;index=1 OR index=2&lt;BR /&gt;
| dedup ID &lt;BR /&gt;
| eval Archief=strptime(field1(existing field in index1),"%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2(existing field in index1),"%Y-%m-%d %H:%M:%S.%N")&lt;/P&gt;

&lt;P&gt;This gives me two fields with epoch time content new fields Archief and DatumWachtkamer.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 11:46:05 GMT</pubDate>
    <dc:creator>jpsolognier</dc:creator>
    <dc:date>2017-10-20T11:46:05Z</dc:date>
    <item>
      <title>Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312670#M93617</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Maybe a simple question, but im struggling with it.&lt;BR /&gt;
I would like to make a new field with eval which consist of two previously made fields with contents out of two indexes.&lt;BR /&gt;
Here is my search query. The new field Dagen does not appear as a new field.&lt;BR /&gt;
Can someone tell what im doing wrong?&lt;/P&gt;

&lt;P&gt;index=1 OR index=2&lt;BR /&gt;
| dedup ID&lt;BR /&gt;&lt;BR /&gt;
| eval Archief=strptime(field1, "%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2, "%Y-%m-%d %H:%M:%S.%N")&lt;BR /&gt;&lt;BR /&gt;
| eval Dagen=floor((Archief-DatumWachtkamer)/86400)&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:11:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312670#M93617</guid>
      <dc:creator>jpsolognier</dc:creator>
      <dc:date>2017-10-20T09:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312671#M93618</link>
      <description>&lt;P&gt;The syntax looks valid, do the fields Archief and DatumWachtkamer both exist in the output?&lt;/P&gt;

&lt;P&gt;The documentation for &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions"&gt;date and time functions&lt;/A&gt; advises that the strptime will convert into a timestamp format (epoch) so I'd expect your query to work...&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:05:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312671#M93618</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2017-10-20T11:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312672#M93619</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;Yes they do.&lt;/P&gt;

&lt;P&gt;Selected Fields&lt;/P&gt;

&lt;H1&gt;Archief    100+&lt;/H1&gt;

&lt;H1&gt;DatumWachtkamer    100+&lt;/H1&gt;

&lt;P&gt;But the last step it doesnt work seems like, so im lost.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312672#M93619</guid>
      <dc:creator>jpsolognier</dc:creator>
      <dc:date>2017-10-20T11:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312673#M93620</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=1 OR index=2 Archief=* DatumWachtkamer=*
| dedup ID 
| eval Archief=strptime(field1, "%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2, "%Y-%m-%d %H:%M:%S.%N") 
| eval Dagen=floor((Archief-DatumWachtkamer)/86400)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312673#M93620</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2017-10-20T11:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312674#M93621</link>
      <description>&lt;P&gt;Hi  jpsolognier,&lt;BR /&gt;
debug your results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=1 OR index=2
| dedup ID 
| eval Archief=strptime(field1,"%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2,"%Y-%m-%d %H:%M:%S.%N") 
| eval Dagen=floor((Archief-DatumWachtkamer)/86400)
| table ID Archief DatumWachtkamer Dagen
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In addition I don't understand a think: you said that you have Archief and DatumWachtkamer in different indexes (index=1 and index=2) and that you can put in relation them using ID, but how can you be sure to have all the values if you dedup by ID? probably you discard some events in this way.&lt;BR /&gt;
Probably it could be better something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=1 OR index=2
| stats earliest(strptime(field1,"%Y-%m-%d %H:%M:%S.%N")) AS Archief earliest(strptime(field2,"%Y-%m-%d %H:%M:%S.%N")) AS DatumWachtkamer BY ID 
| eval Dagen=floor((Archief-DatumWachtkamer)/86400)
| table ID Archief DatumWachtkamer Dagen
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I used earliest but you could also use latest.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312674#M93621</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-20T11:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312675#M93622</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;Archief and DatumWachtkamer are also fields made with eval with time contents from two existing fields that are in two indexes.&lt;/P&gt;

&lt;P&gt;index=1 OR index=2&lt;BR /&gt;
 | dedup ID &lt;BR /&gt;
 | eval Archief=strptime(field1(existing field in index1),"%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2(existing field in index1),"%Y-%m-%d %H:%M:%S.%N") &lt;/P&gt;

&lt;P&gt;This gives me two fields with epoch time content new fields Archief and DatumWachtkamer.&lt;/P&gt;

&lt;P&gt;| dedup ID is used to remove de doubles.&lt;/P&gt;

&lt;P&gt;This is the last piece that is not working: | eval Dagen=floor((Archief-DatumWachtkamer)/86400).&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312675#M93622</guid>
      <dc:creator>jpsolognier</dc:creator>
      <dc:date>2017-10-20T11:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312676#M93623</link>
      <description>&lt;P&gt;Thanks for your suggestion, but it wil not work because of the following:&lt;/P&gt;

&lt;P&gt;Archief and DatumWachtkamer are also fields made with eval with time contents from two existing fields that are in two indexes.&lt;/P&gt;

&lt;P&gt;index=1 OR index=2&lt;BR /&gt;
| dedup ID &lt;BR /&gt;
| eval Archief=strptime(field1(existing field in index1),"%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2(existing field in index1),"%Y-%m-%d %H:%M:%S.%N")&lt;/P&gt;

&lt;P&gt;This gives me two fields with epoch time content new fields Archief and DatumWachtkamer.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:46:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312676#M93623</guid>
      <dc:creator>jpsolognier</dc:creator>
      <dc:date>2017-10-20T11:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312677#M93624</link>
      <description>&lt;P&gt;if you run &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=1 OR index=2
 | dedup ID 
 | eval Archief=strptime(field1,"%Y-%m-%d %H:%M:%S.%N"), DatumWachtkamer=strptime(field2,"%Y-%m-%d %H:%M:%S.%N") 
 | eval Dagen=floor((Archief-DatumWachtkamer)/86400), test=Archief-DatumWachtkamer, Test1=(Archief-DatumWachtkamer)/86400)
 | table ID Archief DatumWachtkamer Dagen Test Test1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;do you have all the fields in all the rows?&lt;BR /&gt;
debug it showing all fields to understand where is the problem.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 11:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312677#M93624</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-20T11:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312678#M93625</link>
      <description>&lt;P&gt;The Archief field is empty, after putting the results in the table. Thats the problem it seems like.&lt;BR /&gt;
This is why the field Dagen is not present with values.&lt;BR /&gt;
Dont understand why.&lt;/P&gt;

&lt;P&gt;But in this step | eval Archief=strptime(field1,"%Y-%m-%d %H:%M:%S.%N") i do see data:&lt;BR /&gt;
Selected Fields&lt;/P&gt;

&lt;H1&gt;Archief    100+&lt;/H1&gt;

&lt;P&gt;And with this step | eval Dagen=floor((Archief-DatumWachtkamer)/86400) the values are not there.&lt;/P&gt;

&lt;P&gt;Weird.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 12:05:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312678#M93625</guid>
      <dc:creator>jpsolognier</dc:creator>
      <dc:date>2017-10-20T12:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need to make a new field with values of new made fields from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312679#M93626</link>
      <description>&lt;P&gt;Hi jpsolognier,&lt;BR /&gt;
probably the problem is the one I described in my first answer: using dedup you delete some events that contain the missed fields.&lt;/P&gt;

&lt;P&gt;Try with the search I suggested&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=1 OR index=2
 | stats earliest(strptime(field1,"%Y-%m-%d %H:%M:%S.%N")) AS Archief earliest(strptime(field2,"%Y-%m-%d %H:%M:%S.%N")) AS DatumWachtkamer BY ID 
 | eval Dagen=floor((Archief-DatumWachtkamer)/86400)
 | table ID Archief DatumWachtkamer Dagen
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this way you should have all fields, if something is missing means that you haven't this value.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 12:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-make-a-new-field-with-values-of-new-made-fields-from-two/m-p/312679#M93626</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-20T12:32:29Z</dc:date>
    </item>
  </channel>
</rss>

