Alert on certain error like 503
bjorn at ruberg.no
Thu Jun 16 15:07:09 CEST 2011
Geoff Simmons <geoff at uplex.de> writes:
> On 06/16/11 01:43 PM, Shibashish wrote:
>> Can varnish be made to send out an alert (mail) in case of an error like
>> 503? I do have a monitoring solution but i can't add all the urls for
>> monitoring. Sometimes varnish gives a 503 and i need to be alerted during
>> that time.
>> Another option can be to keep looking for 503 errors. log them as they occur
>> and keep watching that file.
> If you just want to know that 503s are happening at all, you can monitor
> varnishlog for "NNN TxStatus c 503", although that won't tell you which
> URL got the 503.
> For that, it gets a bit tricky, you'd have to first watch for "NNN RxURL
> c /some/path", and then watch for "NNN c TxStatus" with the same NNN,
> emitting an alert for 503 and forgetting the URL otherwise.
# varnishlog -c -i RxURL,TxStatus -o TxStatus 503
> At any rate, monitoring the varnishlog is the way to do this, we
> wouldn't the Varnish demon itself to start sending email.
Indeed. However, on a not-too-busy server, you could run some cron job
which runs varnishlog like shown above. You might want to investigate
running the above as a daemon writing to a file, then read from that
file in your cron job. The frequency of the cron job must be adjusted to
your server and to how important it is to catch all occurrences, but
you should probably prepare for overlaps and/or gaps :-)
More information about the varnish-misc