<?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 create a query to track received and sent bytes transferred daily through a VPN tunnel? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582638#M202927</link>
    <description>&lt;P&gt;Ok try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 
| bucket _time span=1d
| stats range(rcvdbyte) AS rcvdbyte range(sentbyte) AS sentbyte BY _time tunnelid
| stats sum(rcvdbyte) AS rcvdbyte sum(sentbyte) AS sentbyte BY _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 01:18:59 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-01-27T01:18:59Z</dc:date>
    <item>
      <title>How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/581946#M202717</link>
      <description>&lt;P&gt;I am trying to write a query to calculate the amount of bytes&amp;nbsp; received and sent per day from one of our firewalls at our site to a firewall at another site. This is to create a series of daily metrics for management. I've come up with a query that succeeds most of the time.&lt;/P&gt;&lt;P&gt;Current query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 | bin span=1d _time | stats range(rcvdbyte) as rcvdbyte range(sentbyte) as sentbyte by _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this query fails on days when the vpn tunnel is reset.&amp;nbsp; The rcvdbyte and sentbyte fields that come from the firewall are summed values from the moment the VPN tunnel is started. When the tunnel is reset, it creates a new tunnelid and resets the rcvdbyte, sentbyte, and duration counts to zero. And the current query I am using calculates a massive spike for those days since the range of the rcvdbyte field is now zero minus whatever the previous summed amount of the rcvdbyte field was.&lt;/P&gt;&lt;P&gt;There are a few ways I can think of changing the query to account for when the tunnel is reset. One of my ideas is to track tunnelid over time while still calculating daily rcvdbyte and sentbyte ranges. Another is to somehow track when rcvdbyte or sentbyte or even duration get reset to zero and do a different calculation for that day. Another solution is to just disregard the days when it is reset. However, I haven't been able to implement any of the solutions I have thought of.&lt;/P&gt;&lt;P&gt;Does anyone have any different ideas or know how I can implement one of my ideas?&lt;/P&gt;&lt;P&gt;An example event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;date=2021-06-01 time=23:50:43 device=firewall serialid=1234567891 loggingid=123456789 type=event subtype=vpn loggingdesc="tunnel statistics" loggingmsg="tunnel statistics" action=tunnel-stats remoteip=192.168.1.2 localip=192.168.2.2 remoteport=60000 localport=60000 vpn="site1-to-site2" tunnelid=1234567891 tunneltype="vpn" duration=10170 sentbyte=120 rcvdbyte=360&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 02:52:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/581946#M202717</guid>
      <dc:creator>Mantic</dc:creator>
      <dc:date>2022-01-21T02:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/581957#M202721</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 
| bucket _time span=1d
| stats max(rcvdbyte) AS rcvdbyte max(sentbyte) AS sentbyte BY _time tunnelid
| stats sum(rcvdbyte) AS rcvdbyte sum(sentbyte) AS sentbyte BY _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 07:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/581957#M202721</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-21T07:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582194#M202801</link>
      <description>&lt;P&gt;I tried it and the results aren't quite what I'm expecting, but it may be on the right track.&lt;/P&gt;&lt;P&gt;This query gives rcvdbyte and sentbyte as zero every day except when a tunnel is reset. On the days a tunnel is reset, it gives the range of the max rcvdbyte of the new tunnel minus the max rcvdbyte of the old tunnel. For example:&lt;/P&gt;&lt;TABLE border="1" width="40%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;Date&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;Tunnel ID&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;max rcvdbyte&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;11-30&lt;/TD&gt;&lt;TD width="20%"&gt;200000001&lt;/TD&gt;&lt;TD width="20%"&gt;39555510895&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;12-01&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;200000001&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;41880638036&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;12-01&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;200000002&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;10506504914&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;12-02&lt;/TD&gt;&lt;TD width="20%"&gt;200000002&lt;/TD&gt;&lt;TD width="20%"&gt;16556551565&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Then this query gives:&lt;/P&gt;&lt;TABLE border="1" width="44.446933632035844%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;Date&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;rcvdbyte&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;11-30&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;12-01&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;31374133122&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;12-02&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 24 Jan 2022 04:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582194#M202801</guid>
      <dc:creator>Mantic</dc:creator>
      <dc:date>2022-01-24T04:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582450#M202859</link>
      <description>&lt;P&gt;I'm not sure how the query would have given you those results. Could you run this and let me know the output?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 
| bucket _time span=1d
| stats max(rcvdbyte) AS rcvdbyte max(sentbyte) AS sentbyte BY _time tunnelid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 21:52:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582450#M202859</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-25T21:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582636#M202925</link>
      <description>&lt;P&gt;Oh, I see what I did. Copy and paste error on my part. This is the query I ran:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 
| bucket _time span=1d
| stats max(rcvdbyte) AS rcvdbyte max(sentbyte) AS sentbyte BY _time tunnelid
| stats range(rcvdbyte) as rcvdbyte range(sentbyte) as sentbyte by _time&lt;/LI-CODE&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(rcvdbyte) AS rcvdbyte sum(sentbyte) AS sentbyte BY _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran the corrected query. It sums the max values between tunnels correctly, and I get the data as seen below:&lt;/P&gt;&lt;TABLE border="1" width="56.09729532544687%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;date&lt;/TD&gt;&lt;TD width="25.032258064516128%" height="25px"&gt;rcvdbyte&lt;/TD&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;sentbyte&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;2021-11-30&lt;/TD&gt;&lt;TD width="25.032258064516128%" height="25px"&gt;41878632024&lt;/TD&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;97284896&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;2021-12-01&lt;/TD&gt;&lt;TD width="25.032258064516128%" height="25px"&gt;52387142950&lt;/TD&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;112851721&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;2021-12-02&lt;/TD&gt;&lt;TD width="25.032258064516128%" height="25px"&gt;10506764478&lt;/TD&gt;&lt;TD width="24.903225806451612%" height="25px"&gt;15057101&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But that doesn't quite capture data sent per day. It does sum rcvdbytes and sentbytes between tunnelids at least.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 01:00:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582636#M202925</guid>
      <dc:creator>Mantic</dc:creator>
      <dc:date>2022-01-27T01:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582638#M202927</link>
      <description>&lt;P&gt;Ok try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslogindex device=firewall vpn=site1-to-site2 
| bucket _time span=1d
| stats range(rcvdbyte) AS rcvdbyte range(sentbyte) AS sentbyte BY _time tunnelid
| stats sum(rcvdbyte) AS rcvdbyte sum(sentbyte) AS sentbyte BY _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 01:18:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582638#M202927</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-27T01:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query to track received and sent bytes transferred daily through a VPN tunnel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582658#M202931</link>
      <description>&lt;P&gt;That's exactly what I'm looking for. Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 05:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-to-track-received-and-sent-bytes/m-p/582658#M202931</guid>
      <dc:creator>Mantic</dc:creator>
      <dc:date>2022-01-27T05:44:42Z</dc:date>
    </item>
  </channel>
</rss>

