<?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: Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120380#M32329</link>
    <description>&lt;P&gt;The best approach (one which I am using as well) will be to create a lookup table file for the SLA value and then reference it in your query using lookup command.&lt;/P&gt;

&lt;P&gt;Lookup table: api_sla.csv&lt;BR /&gt;
Lookup Fields: api_name, sla&lt;/P&gt;

&lt;P&gt;Updated (sample query, assuming api name=uri_path, if not use the field which contains api name in the lookup command):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=i1 sourcetype=s1 uri_path="api1" OR uri_path="api2" | eval uri_path=replace(uri_path, "w{8}-w{4}-w{4}-w{4}-w{12}", "{id}") | lookup api_sla.csv api_name as uri_path OUTPUT sla as SLA | stats count as count, count(eval(responsetime&amp;gt;SLA)) as violations,first(SLA) as SLA by uri_path 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:19:11 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-09-28T16:19:11Z</dc:date>
    <item>
      <title>Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120379#M32328</link>
      <description>&lt;P&gt;The use case am working on:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I have one sourcetype, one index. &lt;/LI&gt;
&lt;LI&gt;In the event log there are several apis with responsetime fields.&lt;/LI&gt;
&lt;LI&gt;There is SLA values for responsetime for each API. This is not in the event log as field, but available as values to use in query. &lt;/LI&gt;
&lt;LI&gt;For each of 20 API's in the event log, I need to compute the fraction of violations when response time is greater than SLA given a time range for historic search say past 15 min.&lt;/LI&gt;
&lt;LI&gt;The query needs to determine the count of API's during this time range, number of SLA violations for API during this time range and calculate the fraction of violations. &lt;/LI&gt;
&lt;LI&gt;The SLA value is not same for across API's. Each API has its own SLA value to compute violations&lt;/LI&gt;
&lt;LI&gt;The time range is the same across all API's.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Here is a historic search which could do this easily using append for the past 15 min which I am trying to convert to realtime search.&lt;/P&gt;

&lt;P&gt;index=i1 sourcetype=s1 uri_path="api1"  | eval uri_path=replace(uri_path, "\w{8}-\w{4}-\w{4}-\w{4}-\w{12}", "{id}")  | eval SLA=1000 |  stats count as count, count(eval(responsetime&amp;gt;SLA)) as violations,first(SLA) as SLA by uri_path | append [ search index=i1 sourcetype=s1 uri_path="api2"  | eval uri_path=replace(uri_path, "\w{8}-\w{4}-\w{4}-\w{4}-\w{12}", "{id}")  | eval SLA=750 |  stats count as count, count(eval(responsetime&amp;gt;SLA)) as violations,first(SLA) as SLA by uri_path ]&lt;/P&gt;

&lt;P&gt;But I need to do this in realtime. Append doesnt work for this. I also believe there could be some issues with using multiple real time queries for real time searches like I used to do for historic searches which am not fully sure.&lt;/P&gt;

&lt;P&gt;Here is one which I tried. &lt;/P&gt;

&lt;P&gt;index=i1 sourcetype=s1 uri_path="api1" OR uri_path="api2"  | eval uri_path=replace(uri_path, "\w{8}-\w{4}-\w{4}-\w{4}-\w{12}", "{id}")  | eval SLA=750 |  stats count as count, count(eval(responsetime&amp;gt;SLA)) as violations,first(SLA) as SLA by uri_path&lt;/P&gt;

&lt;P&gt;The issue is SLA value is not the same for all API's. Its different for each API.&lt;/P&gt;

&lt;P&gt;Perhaps there is limitations with using multiple queries in real time. Perhaps a single query should do this when converting the above use case from historic to real time search. Since append doesnt work, am not sure if map, join etc can work also because they involve 2 queries in conjunction.&lt;/P&gt;

&lt;P&gt;I need help with this use case for real time searches in terms of writing splunk query for it.&lt;/P&gt;

&lt;P&gt;In case there are limitations for this use case, an alternative way is to use scheduled historic search every minute. It should also be that the query should run fast and finish quickly within the minute and query performance acceleration could be a consideration.&lt;/P&gt;

&lt;P&gt;Any suggestions for this as well?&lt;/P&gt;

&lt;P&gt;Any help will be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120379#M32328</guid>
      <dc:creator>iTechEvent</dc:creator>
      <dc:date>2020-09-28T16:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120380#M32329</link>
      <description>&lt;P&gt;The best approach (one which I am using as well) will be to create a lookup table file for the SLA value and then reference it in your query using lookup command.&lt;/P&gt;

&lt;P&gt;Lookup table: api_sla.csv&lt;BR /&gt;
Lookup Fields: api_name, sla&lt;/P&gt;

&lt;P&gt;Updated (sample query, assuming api name=uri_path, if not use the field which contains api name in the lookup command):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=i1 sourcetype=s1 uri_path="api1" OR uri_path="api2" | eval uri_path=replace(uri_path, "w{8}-w{4}-w{4}-w{4}-w{12}", "{id}") | lookup api_sla.csv api_name as uri_path OUTPUT sla as SLA | stats count as count, count(eval(responsetime&amp;gt;SLA)) as violations,first(SLA) as SLA by uri_path 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:19:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120380#M32329</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T16:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120381#M32330</link>
      <description>&lt;P&gt;Thanks. Works as expected !&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 14:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120381#M32330</guid>
      <dc:creator>iTechEvent</dc:creator>
      <dc:date>2014-04-04T14:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120382#M32331</link>
      <description>&lt;P&gt;Great. please accept the answer if there are no followup questions.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 14:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120382#M32331</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-04T14:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Real Time Query for SLA violations for each API in sourcetype or alternative approaches if not possible</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120383#M32332</link>
      <description>&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Streamstats"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Streamstats&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It looks like streamstats is more appropriate from streaming perspective. How to explain this to unfamiliar audience. What about the choice of using stats over streamstats. It looks like streamstats is more appropriate for moving average of last 5 events in the entire collection of events in the real time window whereas stats works on the entire collection of events in the real time window.Are we loosing anything by not using streamstats when real time streaming is used?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2014 00:25:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-Needed-with-Real-Time-Query-for-SLA-violations-for-each-API/m-p/120383#M32332</guid>
      <dc:creator>iTechEvent</dc:creator>
      <dc:date>2014-04-07T00:25:54Z</dc:date>
    </item>
  </channel>
</rss>

