<?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 Splunk rest api , if hostname matched in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/520931#M146749</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;I try to if saved search result hostname is matched, reload deploy-server with rest API. But When saved search runs, the deploy server is reloading every time. My saved search cron schedule 5 minutes periods work.&lt;BR /&gt;There is a deploy server reload every 5 minutes.&lt;BR /&gt;How I do, if hostname is matched , reload deploy server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My savedsearches.conf&lt;/P&gt;&lt;P&gt;[Syslog New Source Monitor]&lt;BR /&gt;action.syslogmonitor = 1&lt;BR /&gt;alert.digest_mode = 0&lt;BR /&gt;alert.suppress = 0&lt;BR /&gt;alert.track = 0&lt;BR /&gt;counttype = number of events&lt;BR /&gt;cron_schedule = */5 * * * *&lt;BR /&gt;dispatch.earliest_time = -5m&lt;BR /&gt;dispatch.latest_time = now&lt;BR /&gt;display.general.type = statistics&lt;BR /&gt;display.page.search.tab = statistics&lt;BR /&gt;enableSched = 1&lt;BR /&gt;quantity = 0&lt;BR /&gt;relation = greater than&lt;BR /&gt;request.ui_dispatch_app = search&lt;BR /&gt;request.ui_dispatch_view = search&lt;BR /&gt;search = index=inotify \&lt;BR /&gt;| rex field=_raw "ISDIR\s(?&amp;lt;path&amp;gt;.+)" \&lt;BR /&gt;| eval orig_path="/var/log/splunk/syslog/" \&lt;BR /&gt;| eval new_path=orig_path . path \&lt;BR /&gt;| stats count by host new_path \&lt;BR /&gt;| eval API = case(host=="splunk-sch", \&lt;BR /&gt;[| rest /services/deployment/server/serverclasses//HF%201/reload],host=="splunkfwd", \&lt;BR /&gt;[| rest /services/deployment/server/serverclasses//HF%202/reload], 1=1, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10937i9C92E6AEA2E08D04/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No result doesnt come back but case statement is running.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10936iF67E2BEF07A7F310/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Sep 2020 20:28:53 GMT</pubDate>
    <dc:creator>burakatabay</dc:creator>
    <dc:date>2020-09-22T20:28:53Z</dc:date>
    <item>
      <title>Splunk rest api , if hostname matched</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/520931#M146749</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I try to if saved search result hostname is matched, reload deploy-server with rest API. But When saved search runs, the deploy server is reloading every time. My saved search cron schedule 5 minutes periods work.&lt;BR /&gt;There is a deploy server reload every 5 minutes.&lt;BR /&gt;How I do, if hostname is matched , reload deploy server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My savedsearches.conf&lt;/P&gt;&lt;P&gt;[Syslog New Source Monitor]&lt;BR /&gt;action.syslogmonitor = 1&lt;BR /&gt;alert.digest_mode = 0&lt;BR /&gt;alert.suppress = 0&lt;BR /&gt;alert.track = 0&lt;BR /&gt;counttype = number of events&lt;BR /&gt;cron_schedule = */5 * * * *&lt;BR /&gt;dispatch.earliest_time = -5m&lt;BR /&gt;dispatch.latest_time = now&lt;BR /&gt;display.general.type = statistics&lt;BR /&gt;display.page.search.tab = statistics&lt;BR /&gt;enableSched = 1&lt;BR /&gt;quantity = 0&lt;BR /&gt;relation = greater than&lt;BR /&gt;request.ui_dispatch_app = search&lt;BR /&gt;request.ui_dispatch_view = search&lt;BR /&gt;search = index=inotify \&lt;BR /&gt;| rex field=_raw "ISDIR\s(?&amp;lt;path&amp;gt;.+)" \&lt;BR /&gt;| eval orig_path="/var/log/splunk/syslog/" \&lt;BR /&gt;| eval new_path=orig_path . path \&lt;BR /&gt;| stats count by host new_path \&lt;BR /&gt;| eval API = case(host=="splunk-sch", \&lt;BR /&gt;[| rest /services/deployment/server/serverclasses//HF%201/reload],host=="splunkfwd", \&lt;BR /&gt;[| rest /services/deployment/server/serverclasses//HF%202/reload], 1=1, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10937i9C92E6AEA2E08D04/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No result doesnt come back but case statement is running.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10936iF67E2BEF07A7F310/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 20:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/520931#M146749</guid>
      <dc:creator>burakatabay</dc:creator>
      <dc:date>2020-09-22T20:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk rest api , if hostname matched</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/520932#M146750</link>
      <description>&lt;P&gt;The problem lies in the final &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval API = case(host=="splunk-sch", \
[| rest /services/deployment/server/serverclasses//HF%201/reload],host=="splunkfwd", \
[| rest /services/deployment/server/serverclasses//HF%202/reload], 1=1, 0)&lt;/LI-CODE&gt;&lt;P&gt;The square brackets around each rest command denote a subsearch and subsearches (almost) always execute first.&amp;nbsp; Therefore, the reload command is running before any conditions are tested.&lt;/P&gt;&lt;P&gt;SPL doesn't have conditional execution like programming languages do.&amp;nbsp; You may be able to work around that this way, however.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval API = case(host=="splunk-sch", 
"\| rest /services/deployment/server/serverclasses//HF%201/reload",host=="splunkfwd", 
"\| rest /services/deployment/server/serverclasses//HF%202/reload", 1=1, "noop")
| map search="$API$"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I have to ask, however, what you are trying to accomplish.&amp;nbsp; Reload the deployment server is not a routine task.&amp;nbsp; It's something that is necessary only when the serverclass.conf file is modified.&amp;nbsp; What is the problem you are trying to solve with this search?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 20:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/520932#M146750</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-22T20:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk rest api , if hostname matched</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/521155#M146827</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for answers.&lt;/P&gt;&lt;P&gt;Firstly;&lt;/P&gt;&lt;P&gt;if any result doesn't come back, splunk search is fail.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10953iF4D25F36B258B8BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly;&lt;/P&gt;&lt;P&gt;if any result come back, rest doesn't running.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10955iE503F27E080F574A/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The reason why I want to do this is that, I want this custom alert action python script to trigger when there is a new Syslog added to SplunkHF, the script would add the newly discovered Syslog paths onto the deployment_apps inputs.conf to monitor those new paths and then send the deployed app towards the splunkHF. I have added the correct information to inputs.conf, Incase any results are returned I just want to Reload the related server class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy Splunking.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 20:20:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-rest-api-if-hostname-matched/m-p/521155#M146827</guid>
      <dc:creator>burakatabay</dc:creator>
      <dc:date>2020-09-23T20:20:12Z</dc:date>
    </item>
  </channel>
</rss>

