2

I'm beginning to use Munin to monitor an in-production Nginx server. One thing I'm particularly interested in graphing is the rate of errors--HTTP responses with codes in the 50x range. I'm wondering if:

  1. Is there an existing plugin to do this?
  2. Alternately, what would be the best approach to writing my own plugin. Access log parsing?
David Eyk
  • 667
  • 1
  • 7
  • 17

3 Answers3

4

Well, no such animal existed, so I conjured it.

You'll find the latest code in the gist. Enjoy.

David Eyk
  • 667
  • 1
  • 7
  • 17
1

I am not aware of any out-of-box OSS solutions. I personally wrote this kind of plugin, but cannot share the code. It's two stage:

  1. Log parser to collect fresh statistics (like tail -f). Since you can define Nginx log format, you are free to log the values you want, e.g. status code, upstream request time, etc.
  2. Munin plugin to report the statistics to Munin.

You will have to share the state between these two parts. There is a handful of choices: in memory (my implementation of log parser was event-driven daemon storing all the statistics in memory); MongoDB; Redis; traditionaly MySQL; shared memory; etc.

Alexander Azarov
  • 3,550
  • 21
  • 19
0

So this link is to the nginx plugins in the munin repository. Can't find anything obvious to do what you want, or anything on the web after a (very brief) search.

I wrote a couple of munin plugins and they're not that hard. You should be able to write one to achieve what you want. I would just count the number of 50x errors in the current log and return that as a type DERIVE with a minimum of 0. That way you can just return a single value, and let rrdtool work out if it has increased. Note - this will be an issue if at the end of one day you have say 130 50x errors, and the log gets rotated and you get 131 errors straight away, the graph will think that's a value of 1.

The other option would be to track the count yourself against the log file name and return the actual increase, and reset it when the log rotates.

EightBitTony
  • 9,311
  • 1
  • 34
  • 46