The ekg library now supports user-defined counters. User-defined counters can be used to track custom program state (e.g. the number of requests served by a server.)
Adding a new counter to a program is easy. Here's a small example program:
main = do handle <- forkServer "localhost" 8000 counter <- getCounter "iterations" handle let loop = do inc counter loop loop
The counter will show up in a new section of the web interface, together with a number of built-in counters (e.g. garbage collector and memory usage counters):
All user-defined counters are also available via the REST API.
I've expanded the REST API to allow you to retrieve single counters, with the caveat that single counters can only be retrieved using the "text/plain" MIME type, as the JSON specification doesn't allow simple values (e.g. integers) to occur at the top-level.