<?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: Eval multiple services in single query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750408#M242312</link>
    <description>&lt;P&gt;1. The host=* condition is completely unnecessary. It doesn't narrow your search and every event must have the host field. It's a purely aesthetic remark but bloating the search makes it less readable.&lt;/P&gt;&lt;P&gt;2. The dedup command works differently than I suppose you think it does. After "dedup host" you will be left with just one event containing data for the first service returned by the initial search. All subsequent services for this host will be discarded. I don't think it's what you want.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2025 14:49:01 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2025-07-24T14:49:01Z</dc:date>
    <item>
      <title>Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750397#M242306</link>
      <description>&lt;P&gt;I am attempting to run a query that will find the status fo 3 services and list which ones are failed and which ones are running.&amp;nbsp; I only want to display the host that failed and the statuses of those services.&amp;nbsp; &amp;nbsp;The end goal is to create an alert.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The following query produces no results&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;index="server" host="*" &amp;nbsp;source="Unix:Service" &amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval IPTABLES = if(UNIT=iptables.service AND (ACTIVE="failed" OR ACTIVE="inactive"), "failed", "OK")&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval AUDITD = if(UNIT=auditd.service AND (ACTIVE="failed" OR ACTIVE="inactive"), "failed", "OK")&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval CHRONYD = if(UNIT=chronyd.service AND (ACTIVE="failed" OR ACTIVE="inactive"), "failed", "OK")&lt;/P&gt;&lt;P&gt;| dedup host&amp;nbsp;&lt;/P&gt;&lt;P&gt;| table host IPTABLES AUDITD CHRONYD&lt;BR /&gt;&lt;BR /&gt;This query works&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;index="server" host="*" &amp;nbsp;source="Unix:Service" &amp;nbsp;UNIT=iptables.service&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval IPTABLES = if(ACTIVE="failed" OR ACTIVE="inactive", "failed", "OK")&amp;nbsp;&lt;/P&gt;&lt;P&gt;| dedup host&amp;nbsp;&lt;/P&gt;&lt;P&gt;| table host IPTABLES&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;How can I get the query to produce the following results&lt;BR /&gt;&lt;BR /&gt;host&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPTABLES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AUDITD&amp;nbsp; &amp;nbsp; CHRONYD&lt;BR /&gt;server1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;failed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OK&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 12:52:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750397#M242306</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-07-24T12:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750398#M242307</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/139005"&gt;@cdevoe57&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this bit on its own work?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="server" host="*"  source="Unix:Service"  UNIT=iptables.service &lt;/LI-CODE&gt;&lt;P&gt;If not how about&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="server" host="*"  source="Unix:Service"  UNIT="iptables.service"&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750398#M242307</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-07-24T13:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750399#M242308</link>
      <description>&lt;P&gt;It depends on your actual data. Please share some sample representative events.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:22:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750399#M242308</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-07-24T13:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750404#M242310</link>
      <description>&lt;P&gt;It is from the TA Nix addon&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cdevoe57_0-1753364611642.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39744iDBF32DD01FEE9153/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cdevoe57_0-1753364611642.png" alt="cdevoe57_0-1753364611642.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750404#M242310</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-07-24T13:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750405#M242311</link>
      <description>&lt;P&gt;Yes, this works&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;index="server" host="*" &amp;nbsp;source="Unix:Service" &amp;nbsp;UNIT=iptables.service&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval IPTABLES = if(ACTIVE="failed" OR ACTIVE="inactive", "failed", "OK")&amp;nbsp;&lt;/P&gt;&lt;P&gt;| dedup host&amp;nbsp;&lt;/P&gt;&lt;P&gt;| table host IPTABLES&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:44:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750405#M242311</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-07-24T13:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750408#M242312</link>
      <description>&lt;P&gt;1. The host=* condition is completely unnecessary. It doesn't narrow your search and every event must have the host field. It's a purely aesthetic remark but bloating the search makes it less readable.&lt;/P&gt;&lt;P&gt;2. The dedup command works differently than I suppose you think it does. After "dedup host" you will be left with just one event containing data for the first service returned by the initial search. All subsequent services for this host will be discarded. I don't think it's what you want.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 14:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750408#M242312</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-07-24T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750409#M242313</link>
      <description>&lt;P&gt;Excellent Point.&amp;nbsp; &amp;nbsp;Sadly, I knew that....&amp;nbsp; &amp;nbsp;Must have been a brain cramp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 14:56:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750409#M242313</guid>
      <dc:creator>cdevoe57</dc:creator>
      <dc:date>2025-07-24T14:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750431#M242326</link>
      <description>&lt;P&gt;This syntax is wrong and will never work&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval IPTABLES = if(UNIT=iptables.service AND (ACTIVE="failed" OR ACTIVE="inactive"), "failed", "OK") &lt;/LI-CODE&gt;&lt;P&gt;UNIT is a string, so must be quoted as you have done for the ACTIVE field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval IPTABLES = if(UNIT="iptables.service" AND (ACTIVE="failed" OR ACTIVE="inactive"), "failed", "OK") &lt;/LI-CODE&gt;&lt;P&gt;You probably want to use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields _time host IPTABLES AUDITD CHRONYD
| stats latest(*) as * by host&lt;/LI-CODE&gt;&lt;P&gt;to get you the most recent state&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 23:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750431#M242326</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-07-24T23:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Eval multiple services in single query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750437#M242330</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/139005"&gt;@cdevoe57&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Try below,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="server" source="Unix:Service" UNIT IN ("iptables.service", "auditd.service", "chronyd.service")
| eval status=if(ACTIVE=="failed" OR ACTIVE=="inactive", "failed", "OK")
| eval service=case(
    UNIT=="iptables.service", "IPTABLES",
    UNIT=="auditd.service", "AUDITD",
    UNIT=="chronyd.service", "CHRONYD"
)
| stats values(status) as status by host service
| xyseries host service status
| where IPTABLES="failed" OR AUDITD="failed" OR CHRONYD="failed"
| table host IPTABLES AUDITD CHRONYD&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="demo1_1.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39745iA145B349E4D3FA7F/image-size/large?v=v2&amp;amp;px=999" role="button" title="demo1_1.JPG" alt="demo1_1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2025 05:02:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-multiple-services-in-single-query/m-p/750437#M242330</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-07-25T05:02:22Z</dc:date>
    </item>
  </channel>
</rss>

