Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
M1kemclain247
New Contributor

FortiAnalyzer Custom Report for Browsing Usage based on Subnet Filters

Hi , I'm trying to setup a custom Report to show all users browsing activity in a customers network. 
so for example user A - consumed maybe 5gb on whatsapp - 2gb office updates etc... just to break down what their doing on the network at a glance.  and filter based on the subnet their in so for guest users see what's going execs etc... 

based on subnets e.g.: 

VLAN1 - LAN  (10.214.11.0/24)
VLAN2 - CCTV (10.213.11.0/24)
VLAN3 - GUEST (10.212.11.0/24)
VLAN4 - CORP WIFI (10.211.11.0/24)

Essentially i want to be able to just generate a report and specify the subnet when running the report. 
I have tried doing this with a custom dataset but as soon as i specify the Subnet the report generates blank content. 
Running - FAZVM64 KVM - v7.4.6 build2588 (Mature)


 

 

 

SELECT
  user_src,
  hostname AS website,
  SUM(minutes) AS total_time_minutes,
  SUM(bandwidth) AS total_bandwidth
FROM
  (
    SELECT
      count(dtime) AS minutes,
      ipstr(srcip) AS user_src,
      hostname,
      SUM(COALESCE(sentbyte, 0) + COALESCE(rcvdbyte, 0)) AS bandwidth
    FROM
      $log-traffic
    WHERE
      $filter
      AND srcip::inet >= '10.214.11.0'::inet
      AND srcip::inet <= '10.214.11.255'::inet
    GROUP BY
      user_src,
      hostname
  ) t
GROUP BY
  user_src,
  website
ORDER BY
  user_src,
  total_time_minutes DESC

 

 

 



This is a sample SQL query i have tried to come up , but can only get it working when i specify inside the dataset the subnets like this. 
chart_execs.png

The Report shows this which is perfect - but noticing its also capturing some public IPs as sources. so assuming something wrong with my SQL query. 

report_execs.png

If anyone has some pointers on how i can do this effectively - and still have the ability to customize before executing the report choosing the subnet i want to run the report for - i haven't quite understood how i can pass that variable into the dataset. as seen below 
Subnets.png


FortiAnalyzer  

M1kes
M1kes
4 REPLIES 4
Stephen_G
Moderator
Moderator

Hello,


Thank you for using the Community Forum. I will seek to get you an answer or help. We will reply to this thread with an update as soon as possible.


Thanks,

Stephen - Fortinet Community Team
Stephen_G
Moderator
Moderator

Hi,

 

We're still looking for an answers or help. In the meantime, if anyone has any input on the topic, it's very welcome!

Stephen - Fortinet Community Team
M1kemclain247
New Contributor

Let me add this for context :

running below query in the dataset: you can see an output of the query correctly showing results here
Dataset Query.png

SELECT
  user_src,
  srcip,
  hostname AS website,
  SUM(minutes) AS total_time_minutes,
  SUM(bandwidth) AS total_bandwidth
FROM
  (
    SELECT
      count(dtime) AS minutes,
      COALESCE(
        nullifna(`user`),
        nullifna(`unauthuser`)
      ) AS user_src,
      ipstr(`srcip`) AS srcip,
      hostname,
      sum(COALESCE(sentbyte, 0) + COALESCE(rcvdbyte, 0)) AS bandwidth
    FROM
      $log-traffic
    WHERE
      $filter
      AND hostname IS NOT NULL
      AND logid_to_int(logid) NOT IN (4, 7, 14)
      AND (
        countweb > 0
        OR (
          (
            logver IS NULL
            OR logver < 52
          )
          AND (
            hostname IS NOT NULL
            OR utmevent IN (
              'webfilter',
              'banned-word',
              'web-content',
              'command-block',
              'script-filter'
            )
          )
        )
      )
    GROUP BY
      user_src,
      srcip,
      hostname
  ) t
GROUP BY
  user_src,
  srcip,
  website
HAVING
  SUM(bandwidth) > 20
ORDER BY
  user_src,
  total_time_minutes DESC

 

if i select the subnet in the report settings before running - it generates blank reports. 
However if i run without specifying any subnet it returns full results - but its so large we want to only do it for specific subnets of users. 
Specify subnet.png

  FROM
      $log-traffic
    WHERE
      $filter


$Filter - i would assume would contain some variables parsed into the final query when we run the report. so my assumption is that maybe the way that's being interpreted is invalid or something wrong with the syntax maybe - if there was a way we could view what the final preview query running is - that could lead us into a direction to find what's going wrong? 

 

Example 1: Report generated with subnet specified: returns empty report 
Blank Report.png

 

Example 2: Report generated without specifying any subnet filter. works fine
Full Report.png


M1kes
M1kes
czamudio
Staff
Staff

Hi,

it's a bug,  when using some netmasks, it is expected to  be fixed on 7.4.7 

 

Cuauhtemoc Zamudio Technical Support Engineer – LATAM ETAC M-F 09:00-18:00 Hrs. Central Time T: +1 408-542-7780
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors