On Mon, Nov 02, 2015 at 09:27:45AM +0100, Baptiste wrote:
> I was delivering the "quick" answer to have this feature right now :)
> 
> This is a need we identified and I already talked to Willy about it.
> There is technically nothing against such feature.
> We need time or resource to develop it.
> If you want to contribute, write a similar function than csv_enc() in
> src/standard.c.

Not exactly, as csv_enc() is only used to encode one string at a time. The
proper approach is to change the stats output to emit an indexed array for
values that will be used both by the existing CSV and HTML outputs. Then
it will be much easier to emit JSON as well. I'm not interested in seeing
any work towards JSON before addressing the current model. Indeed, most of
the information is present in the HTML output and is not available through
CSV. So if we're going to have a third output format with even different
fields, it becomes a real mess.

So to summarize, here are the actions :

  1) scrutinize the HTML output format to enumerate all the data we need to
     get ; HTML output will not be allowed to perform any computation anymore,
     only representation. So each value needs to have one entry ;

  2) create a huge enum and assign non-ambiguous names to each values ; declare
     an array of "values" (I think we need 64bit ints and strings at least). We
     can have two arrays if we suffic each enum with its type (eg: FOO_S for a
     string, FOO_I for an int, maybe later FOO_F for a float).

  3) write a function to fill th{is,ese} array[s] for the current proxy and
     server

  4) reimplement HTML and CSV outputs by calling this function and picking the
     values from the indexed array[s]. The iterators are still in these output
     formats which serve as templates.
 
  5) write the equivalent JSON output


  6) add the ability to request JSON output on the HTTP stats request line
     just like we have ";csv" for CSV. It may be nice to see if we can have
     something similar on the CLI at least for debugging, and possibly for
     better interfacing with monitoring daemons

  7) see how we can do the same for the global per-process info that are
     currently reported in the HTML version and in "show info" but not in
     the CSV output. I think the JSON output will be able to dump them at the
     same time as the other ones. Maybe for the HTTP access we'll just ask
     ";info" to get them in CSV format.

Willy


Reply via email to