varnish / varnish-modules

Collection of Varnish Cache modules (vmods) by Varnish Software
Other
182 stars 86 forks source link

Operational status from saintmode #43

Closed espebra closed 8 years ago

espebra commented 8 years ago

Saintmode maintains some internal state (related to blacklist and duration) that is taken into account when figuring out the health of a backend. Its operation is currently similar to a black box due to the lack of log entries and counters, which makes it cumbersome to verify that saintmode is enabled and is working as expected.

It would be nice with counters and/or log entries that are related to its operational status.

dridi commented 8 years ago

We can't have counters that are not defined at compile-time in Varnish. We can definitely log.

It should also be possible to have a method for returning the internal status of a saintmode backend (à la rtstatus). For use in vcl_synth.

daghf commented 8 years ago

Fixed.

saintmode will now spit out a few new loglines:

1003 VCL_Log         b saintmode: unhealthy: object blacklisted for backend s1

and

1020 VCL_Log         b saintmode: unhealthy: hit threshold for backend s1

and

1002 VCL_Log         b saintmode: object put on blacklist for backend s1 for 0.50 seconds

In addition I added @Dridi's suggestion of having an rtstatus-like overall status:

$ curl http://localhost:9090/saintmode-status 
{
    "saintmode": [
        { "name": "sm0", "backend": "b0", "count": "0", "threshold": "5" },
        { "name": "sm1", "backend": "b1", "count": "0", "threshold": "4" }
    ]
}

And also a function to inspect the troublelist length specifically for a single saintmode object:

    set resp.http.count = sm.blacklist_count();