Due to the nature of my application, my server is getting bombarded with requests the majority of which are non-generic. Out of a ~30MB access.log per day only about 1MB represents real users. This has led me to the decision to disable the access logs altogether.

I would still however like to know at least how many requests Apache is serving daily. Is it possible to log only the number of requests served without any additional information?

I thought about using a custom log format with a single character and then count the lines but that'd be kind of hacky, decided to ask if there is a cleaner solution.

  • Why not just logrotate them out? That way you can wc -l on the log (or even grep out those with no referrer). 30MB doesn't seem like a killer from a storage viewpoint. – tater Sep 7 at 9:40
  • @tetech well it is degrading performance and ssd life even if insignificantly. im guessing its more of a mindset - don't do work that doesn't have to be done. – php_nub_qq Sep 7 at 9:44
  • 30MB/day is trivially small. It's hardly worth worrying about disk space usage. Nor SSD wear. It would take many years to wear out the SSD at that rate and would be long obsolete before it wore out. – Michael Hampton Sep 7 at 15:08
  • @MichaelHampton but still, why do it if it's useless anyway? Furthermore I'd like to prolong the life of that machine for as long as possible because sadly I'm the one who'd have to take care of it would it happen to die and that's something I'm definitely not looking forward to. – php_nub_qq Sep 7 at 18:28
  • I will be quite surprised if you still have that machine in 2050. – Michael Hampton Sep 7 at 19:14

mod_status provides counters for total requests and total bytes served, plus some more stats. If all you need is total numbers (not by path/status/etc) this works. https://httpd.apache.org/docs/2.4/mod/mod_status.html

You can configure a Prometheus exporter to scrape it, so it will be available for graphing, alerting and analyzing trend over time: https://github.com/Lusitaniae/apache_exporter

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.