<?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: Searching on consecutive lines in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-consecutive-lines/m-p/690936#M235309</link>
    <description>&lt;P&gt;In the "better late than never" category of answers (and I realize this answer might not have been available in previous versions of Splunk)...&lt;BR /&gt;&lt;BR /&gt;It's unclear, from the original question, if the "ip:port" belongs to the service, or the client.&lt;BR /&gt;&lt;BR /&gt;If it belongs to the service, then every timeout uniquely identifies the service, and all that needs to be done is to count the timeouts, and then map in the service name:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval data="CONNECTION-1.1.1.1:1: connect() timeout,[service_with_2_timeouts] tearing down tcp connection [1.1.1.1.1],CONNECTION-1.1.1.2:2: connect() timeout,[service_with_1_timeout] tearing down tcp connection [1.1.1.2.2],[service_with_no_timeouts] tearing down tcp connection [1.1.1.3.3],CONNECTION-1.1.1.1:1: connect() timeout,[service_with_2_timeouts] tearing down tcp connection [1.1.1.1.1]"
| eval mvdata=split(data,",")
| mvexpand mvdata
``` Everything above this is to generate sample data ```
| eval is_timeout=if(like(mvdata,"%connect() timeout%"),1,0)
| rex field=mvdata "CONNECTION-(?&amp;lt;ip&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(?&amp;lt;port&amp;gt;\d+): connect\(\) timeout"
| rex field=mvdata "\[(?&amp;lt;service_name&amp;gt;[^\]]+)\] tearing down tcp connection \[(?&amp;lt;ip&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.(?&amp;lt;port&amp;gt;\d+)\]"
| stats first(service_name) as service_name, sum(is_timeout) as timeout_count by ip, port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If, on the other hand, the "ip:port" belong to the client accessing the service, this is a bit more complicated, with too many potential solutions depending on details not available here.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 00:29:39 GMT</pubDate>
    <dc:creator>P_vandereerden</dc:creator>
    <dc:date>2024-06-18T00:29:39Z</dc:date>
    <item>
      <title>Searching on consecutive lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-consecutive-lines/m-p/120924#M184065</link>
      <description>&lt;P&gt;My logs output two consecutive lines in the case of a connection timeout:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... CONNECTION-x.x.x.x:y: connect() timeout
... [service_name] tearing down tcp connection [x.x.x.x.y]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where x.x.x.x:y is the ip:port and service_name is some string. How do I put together a splunk query to basically end up with a table of the # of timeouts for each service_name?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 13:50:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-consecutive-lines/m-p/120924#M184065</guid>
      <dc:creator>Sphere991</dc:creator>
      <dc:date>2014-09-11T13:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Searching on consecutive lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-consecutive-lines/m-p/690936#M235309</link>
      <description>&lt;P&gt;In the "better late than never" category of answers (and I realize this answer might not have been available in previous versions of Splunk)...&lt;BR /&gt;&lt;BR /&gt;It's unclear, from the original question, if the "ip:port" belongs to the service, or the client.&lt;BR /&gt;&lt;BR /&gt;If it belongs to the service, then every timeout uniquely identifies the service, and all that needs to be done is to count the timeouts, and then map in the service name:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval data="CONNECTION-1.1.1.1:1: connect() timeout,[service_with_2_timeouts] tearing down tcp connection [1.1.1.1.1],CONNECTION-1.1.1.2:2: connect() timeout,[service_with_1_timeout] tearing down tcp connection [1.1.1.2.2],[service_with_no_timeouts] tearing down tcp connection [1.1.1.3.3],CONNECTION-1.1.1.1:1: connect() timeout,[service_with_2_timeouts] tearing down tcp connection [1.1.1.1.1]"
| eval mvdata=split(data,",")
| mvexpand mvdata
``` Everything above this is to generate sample data ```
| eval is_timeout=if(like(mvdata,"%connect() timeout%"),1,0)
| rex field=mvdata "CONNECTION-(?&amp;lt;ip&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(?&amp;lt;port&amp;gt;\d+): connect\(\) timeout"
| rex field=mvdata "\[(?&amp;lt;service_name&amp;gt;[^\]]+)\] tearing down tcp connection \[(?&amp;lt;ip&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.(?&amp;lt;port&amp;gt;\d+)\]"
| stats first(service_name) as service_name, sum(is_timeout) as timeout_count by ip, port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If, on the other hand, the "ip:port" belong to the client accessing the service, this is a bit more complicated, with too many potential solutions depending on details not available here.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 00:29:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-consecutive-lines/m-p/690936#M235309</guid>
      <dc:creator>P_vandereerden</dc:creator>
      <dc:date>2024-06-18T00:29:39Z</dc:date>
    </item>
  </channel>
</rss>

