<?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 find field value, based on where condition, and assign to variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658887#M227555</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/67872"&gt;@sarge338&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let me understand: you have three syslog sources to ingest in Splunk, and then you whould compare events from the three sources, is it correct?&lt;/P&gt;&lt;P&gt;if this is your requirements you should follow these preliminary steps to ingest data (if you already ingested data jump these steps):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;identify the data type (technology, model, type of data),&lt;/LI&gt;&lt;LI&gt;identify IP address, protocol and port of each source,&lt;/LI&gt;&lt;LI&gt;identify the correct Add-on to parse these data source,&lt;/LI&gt;&lt;LI&gt;put in listening your heavy forwarder on the defined ports and protocols,&lt;/LI&gt;&lt;LI&gt;configure your sources to send logs to the heavy forwarder using the defined protocol and port,&lt;/LI&gt;&lt;LI&gt;configure the input on heavy forwarder assigning the correct sourcetype (based on the choosed Add-On) and the correct index,&lt;/LI&gt;&lt;LI&gt;the host is automatically assigned using the IP address.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;then in your Splunk you can run a search like the following (Not having any information on data sources I cannot be detailed and I could be vague):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| stats dc(host) AS host_count BY _time
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;if the timestamps must be exactly the same, if instead they must be similar (e.g. 5 minutes ranges), you could run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| bin span=5m _time
| stats dc(host) AS host_count BY _time
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;In this way you have the events with the same timestamp in all the hosts, if you want a different condition, you have to modify the final where command.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 16:50:45 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-09-27T16:50:45Z</dc:date>
    <item>
      <title>How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658886#M227554</link>
      <description>&lt;P&gt;Good Morning!&lt;/P&gt;&lt;P&gt;I rarely get to dabble in SPL, and as such, some (probably simple) things stump me.&amp;nbsp; That is what brought me here today.&lt;/P&gt;&lt;P&gt;I have a scenario in which I need to pull SYSLOG events from a series of machines that all report the field names.&amp;nbsp; One of those machines is the authoritative source of values, which all of the other systems should have.&amp;nbsp; As an example, I have 3 machines... M1, M2, M3, and each machine reports three field/value pairs... sync-timestamp, version-number, machine-name.&lt;BR /&gt;&lt;BR /&gt;I need to compare the sync-timestamp of M1 with the sync-timestamp of the other two machines.&amp;nbsp; My idea is to assign the "sync-timestamp value WHERE computer-name=M1" to a variable by which to compare the other two machines' values.&amp;nbsp; I intend to use this report to ultimately create an alert, so we know if machines are not syncing properly.&lt;/P&gt;&lt;P&gt;I just cannot figure out the syntax to make this happen.&amp;nbsp; Can anyone provide some guidance on this?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 16:25:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658886#M227554</guid>
      <dc:creator>sarge338</dc:creator>
      <dc:date>2023-09-27T16:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658887#M227555</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/67872"&gt;@sarge338&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let me understand: you have three syslog sources to ingest in Splunk, and then you whould compare events from the three sources, is it correct?&lt;/P&gt;&lt;P&gt;if this is your requirements you should follow these preliminary steps to ingest data (if you already ingested data jump these steps):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;identify the data type (technology, model, type of data),&lt;/LI&gt;&lt;LI&gt;identify IP address, protocol and port of each source,&lt;/LI&gt;&lt;LI&gt;identify the correct Add-on to parse these data source,&lt;/LI&gt;&lt;LI&gt;put in listening your heavy forwarder on the defined ports and protocols,&lt;/LI&gt;&lt;LI&gt;configure your sources to send logs to the heavy forwarder using the defined protocol and port,&lt;/LI&gt;&lt;LI&gt;configure the input on heavy forwarder assigning the correct sourcetype (based on the choosed Add-On) and the correct index,&lt;/LI&gt;&lt;LI&gt;the host is automatically assigned using the IP address.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;then in your Splunk you can run a search like the following (Not having any information on data sources I cannot be detailed and I could be vague):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| stats dc(host) AS host_count BY _time
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;if the timestamps must be exactly the same, if instead they must be similar (e.g. 5 minutes ranges), you could run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| bin span=5m _time
| stats dc(host) AS host_count BY _time
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;In this way you have the events with the same timestamp in all the hosts, if you want a different condition, you have to modify the final where command.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 16:50:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658887#M227555</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-27T16:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658891#M227557</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The data is already being ingested into Splunk, and if I look at events from the last 10 minutes (index="my-index" earliest=-10m@m latest=@m), the syslog messages from ALL machines are showing up as a single event timestamp.&amp;nbsp; So, I need to compare the sync-time field, which is is epoch, rather than the _time value assigned by Splunk.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 17:59:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658891#M227557</guid>
      <dc:creator>sarge338</dc:creator>
      <dc:date>2023-09-27T17:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658918#M227567</link>
      <description>&lt;P&gt;You need to collect the sync-timestamp field from M1 to the other events and then compare, which can be done using eventstats, as in this example.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults  count=3
| streamstats c
| eval machine-name="M".c
| eval sync-timestamp=now() - 300 + (if(c=3,60,0)), version-number="1.2.3"
``` Data setup above where M3 is 1 minute in front of M1 and M2 ```

``` Collect the master timestamp to the other events ```
| eventstats values(eval(if('machine-name'="M1", 'sync-timestamp', null()))) as m1-timestamp

| where 'sync-timestamp'!='m1-timestamp'&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 27 Sep 2023 22:36:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658918#M227567</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-27T22:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658932#M227574</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/67872"&gt;@sarge338&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;the solution is the same using the sync-time field instead _time, being in epochtime it's easier to manage.&lt;/P&gt;&lt;P&gt;As I said you have only to define if you want the exact sync-time or a period (e.g. 5 minutes) and what's the rule to apply filter.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| stats dc(host) AS host_count BY "time-sync"
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;if the timestamps must be exactly the same, if instead they must be similar (e.g. 5 minutes ranges), you could run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index host IN (M1, M2, M3)
| bin span=5m "time-sync"
| stats dc(host) AS host_count BY "time-sync"
| where host_count=3&lt;/LI-CODE&gt;&lt;P&gt;If possible, don't use the minus char "-", but understand char "_", because Splunk read it as the minus operator, so yu have to use quotes.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 05:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/658932#M227574</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-28T05:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/667350#M228934</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp; Thank you for all of your help!&amp;nbsp; I apologize for the lag in responding to you.&amp;nbsp; I have been very busy on another project.&amp;nbsp; Your suggestion was spot-on, though, so I wanted to be sure to thank you for your assistance.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/667350#M228934</guid>
      <dc:creator>sarge338</dc:creator>
      <dc:date>2023-11-03T18:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find field value, based on where condition, and assign to variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/667375#M228951</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/67872"&gt;@sarge338&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 13:12:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-field-value-based-on-where-condition-and-assign-to/m-p/667375#M228951</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-11-04T13:12:05Z</dc:date>
    </item>
  </channel>
</rss>

