Pfsense ntop getting prometheus data

Posted on Sunday, February 14, 2021


 

I have pfsense with ntopng installed on it.
I would like to get some of this data from ntop into my prometheus se

so I can make cool graphs of my data usage in Grafana.

 

 

 

 

 


 

Ntopng installed

 

If you do not have ntopng installed you can check out my post on it here http://www.whiteboardcoder.com/2018/12/installing-ntopng-on-pfsense.html [1]

 

 


 

 

Open up ntopng under the Diagnostics menu



This will require a login

After you login open up the /metrics page
In my case its https://192.168.0.1:3000/metrics

 

 


You should see lots of prometheus style data points


Now you can get prometheus to pull data from here using this URL but you would also need to give prometheus the user name and password for your admin.  Probably a bad idea.

Instead let’s make a limited user.

 

 

 

Click on Manage Users

On the far right click Add a User

 



Make a new user but make them Non Privilaged.
Now we can use this user to get the data from.



Update Prometheus scrape settings

 

My prometheus has its setting file at sudo vi /prometheus/prometheus.yml see http://www.whiteboardcoder.com/2021/01/installing-prometheus-on-ubuntu-2004.html [2] if you are curious how I set it up.

 


  > sudo vi /prometheus/prometheus.yml

 

And add the following to scrape

 


  - job_name: 'pfsense_topng'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.0.1:3000']
    scheme: https
    basic_auth:
      username: 'prometheus'
      password: 'prometheus'
    tls_config:
        insecure_skip_verify: true






Save the file and restart prometheus



  > sudo systemctl restart prometheus

 

It may be a good idea to confirm that it is not being scraped

Let me log back into my prometheus server but pull port 9090/3000 to local

 


  > ssh prometheus -L 9090:localhost:9090 -L 3000:localhost:3000


Open
http://localhost:9090/targets

 

I can see that it is pulling info.

 


 

Now what do with the info in Grafana?

 

Let me log into grafana and make a new board

http://localhost:3000/

 



 




 


Now for some fun queries to get data out.
Let me run a curl with password on it.

 


  > curl -s --insecure -u prometheus:prometheus https://192.168.0.1:3000/metrics

 

OK now grep it

 


  > curl -s --insecure -u prometheus:prometheus https://192.168.0.1:3000/metrics \
 | egrep stats.bytes.sent | egrep igb0

 

 

Here are some queries I came up with

 

The total of Bytes sent from interface igb0 (my wan) per hour rate


sum(increase(hosts{ifname="igb0",metric="stats.bytes.sent"} [1h]))

 


The total of Bytes received from interface igb0 (my wan) per hour rate


sum(increase(hosts{ifname="igb0",metric="stats.bytes.rcvd"} [1m]))

 

The total of Bytes sent from interface igb0 (my wan) per hour rate


12*sum(increase(hosts{ifname="igb0",metric="stats.bytes.sent"} [5m]))

 

The total of Bytes received from interface igb0 (my wan) per hour rate


12*sum(increase(hosts{ifname="igb0",metric="stats.bytes.rcvd"} [5m]))

 


 



sum(increase(hosts{ifname="igb0",metric="stats.bytes.rcvd"} [28d]))/(1024*1024*1024) + sum(increase(hosts{ifname="igb0",metric="stats.bytes.sent"} [28d]))/(1024*1024*1024)


 

Total in and out over a 28 day period

 

Who are my offenders on my other networks..


Who received  more than 2GiB/hr rate

 


increase(hosts{ifname="igb1",metric="stats.bytes.rcvd"} [1h]) > 2*1024*1024*1024


 

Who sent more than 2 GiB /hr rate


increase(hosts{ifname="igb1",metric="stats.bytes.sent"} [1h]) > 2*1024*1024*1024

 


After a little fiddling

 

 

 

Of course I have had data coming in for a few weeks now so your mileage may vary until you have more data.


My one gripe so far on this would it would be nice if they added hostname to the data.  I do get the IP address of offenders but then I have to go look it up.

 

 


A word of warning …

Looks like this prometheus export was experimental and has been dropped in ntopng 4.0
https://github.com/ntop/ntopng/issues/3705 


 

 

References

 

[1]        Installing ntopng on pfsense
              
http://www.whiteboardcoder.com/2018/12/installing-ntopng-on-pfsense.html
             Accessed 02/2021

[2]        Installing Prometheus on Ubuntu 20.04

http://www.whiteboardcoder.com/2021/01/installing-prometheus-on-ubuntu-2004.html
Accessed 02/2021

 

 

 

 

28 comments:

  1. Awesome article. I enjoyed reading your articles. this can be really a good scan for me. wanting forward to reading new articles. maintain the nice work!
    Data Science Courses in Bangalore

    ReplyDelete
  2. I found Habit to be a transparent site, a social hub that is a conglomerate of buyers and sellers willing to offer digital advice online at a decent cost.

    Artificial Intelligence Training in Bangalore

    ReplyDelete
  3. Unfortunately the developers have removed the support for Prometheus https://github.com/ntop/ntopng/issues/3705

    ReplyDelete
  4. I just got to this amazing site not long ago was actually captured with the piece of resources you have got here and big thumbs up for making such wonderful blog page!
    Data Scientist Course

    ReplyDelete
  5. Excellent post to make this blog more wonderful, attractive and cool stuff you have. Thank You.
    Data Science Course in India with Placements

    ReplyDelete
  6. You have done excellent job Thanks a lot and I enjoyed your blog. Great Post.
    Ethical Hacking Course in Hyderabad

    ReplyDelete
  7. Do you want to make sure your digital marketing services is on the right track? Digital World Giant is one of the most renowned agencies in New York. They specialize in Web Development, Digital Marketing and SEO services.

    ReplyDelete
  8. Thank you for sharing this wonderful blog, I read that Post and got it fine and informative. Please share more like that...
    Ethical Hacking Institute in Bangalore

    ReplyDelete
  9. Nice Post thank you very much for sharing such a useful information and will definitely saved and revisit your site and i have bookmarked to check out new things frm your post.
    Data Science Course

    ReplyDelete
  10. Very interesting blog. A lot of the blogs I see these days don't provide anything that interests me, but I'm really interested in this one. I just thought I would post and let you know.

    Data Science Course in Ernakulam

    ReplyDelete
  11. I have read your article, it is very informative and useful to me, I admire the valuable information you offer in your articles. Thanks for posting it ...

    Data Science Course in Durgapur

    ReplyDelete
  12. I am excited about this blog. It is an informative subject. It helped me a lot in solving some problems. Your opportunity is so fantastic and the style of work so fast.

    Data Science Training in Ernakulam

    ReplyDelete
  13. Very nice job... Thanks for sharing this amazing and educative blog post!
    Data Science Course in Chandigarh

    ReplyDelete
  14. This is an excellent article. I like this topic. This site has many advantages. I have found a lot of interesting things on this site. It helps me in so many ways. Thanks for posting this again.

    Data Analytics Course in Durgapur

    ReplyDelete
  15. I always search online for articles that can help me. Obviously, there is a lot to know about this. I think you made a few good points about the features as well. Keep up the good work!

    Data Scientist Course in Ernakulam

    ReplyDelete
  16. Very informative Blog! There is so much information here that can help thank you for sharing.
    Data Analytics Training in Bangalore

    ReplyDelete
  17. Good blog and absolutely exceptional. You can do a lot better, but I still say it's perfect. Keep doing your best.

    Data Analytics Course in Nagpur

    ReplyDelete
  18. I really appreciate this wonderful message you have given us. I assure you that would be beneficial for most people.

    Data Analytics Course in Nagpur

    ReplyDelete
  19. Wonderful blog post. It's absolute magic on your part! I have never seen a more wonderful article than this. You really made my day today with this. Hope you continue like this!

    Data Scientist Course in Patna

    ReplyDelete
  20. Wonderful illustrated information. Thank you. It will certainly be very useful for my future projects. I would love to see more articles on the same topic!

    Data Science Training in Bangalore

    ReplyDelete
  21. Happy to chat on your blog, I feel like I can't wait to read more reliable posts and think we all want to thank many blog posts to share with us.

    Data Science Training Institutes in Bangalore

    ReplyDelete
  22. Thank you very much for this interesting article. In fact, it is exceptional. You are looking for this type of notice later.

    Data Scientist Course in Nagpur

    ReplyDelete
  23. This is just the information I find everywhere. Thank you for your blog, I just subscribed to your blog. It's a good blog.

    Best Data Analytics Courses in Bangalore

    ReplyDelete
  24. Really nice and amazing post. I was looking for this kind of information, Keep posting. Thanks for sharing.
    Data Science Courses in Bangalore

    ReplyDelete
  25. Really impressed! Information shared was very helpful Your website is very valuable. Thanks for sharing.
    Food Technology Consultant

    ReplyDelete
  26. Thanks for sharing this great article we appreciate it, we provide down video from facebook freely and unlimited.

    ReplyDelete
  27. uraqt.xyz Entertainment information and creative ideas.

    ReplyDelete