Thanks to an excellent suggestion from @d55m14, here is a first attempt to provide some editing capability for Whisper files…
Rather than augmenting the DataYours plugin, I’ve written this as a stand-alone WSAPI CGI which you can easily add to an openLuup system. The CGI provides server-side access to reading and writing portions of Whisper files, through GET and POST requests, in a JSON-encoded format, identical to that used in Carbon/Graphite (and DataGraph) and documented here: https://graphite.readthedocs.io/en/latest/render_api.html#data-display-formats.
In addition to the CGI, I’ve also written a very crude web page with two forms (READ / WRITE) which can exercise the functionality. Although this is very basic it can, in fact, be used successfully to edit errant values in Whisper files without too much difficulty.
You just need to place these two files:
[ul][li]whisper-editor.lua - into /etc/cmh-ludl/cgi/[/li]
[li]whisper-editor.html - into /etc/cmh-ludl/[/li][/ul]
You do need to run this on an openLuup system with DataYours up and running (it uses DataYours to find the Whisper database.)
No need for a system reload - the CGI .lua file will be loaded on request.
To access the test web page simply browse the following URL:
A snapshot of the page displayed is shown below. To understand its use, here’s an overview of the GET/POST parameters:
The request is of the form:
[ul][li]target - metric name to be read (Whisper filename without the .wsp extension)[/li]
[li]from - an ISO-8601 formatted datetime at which to begin[/li]
[li]until - an ISO-8601 formatted datetime at which to end[/li][/ul]
The demo webpage uses an input field of type datetime-local so depending on your browser, this may display as a date-picker (sadly, Firefox does not do this, although Safari does)
The request content uses enctype=“text/plain” and the content itself should be a JSON-encoded format identical to that which the READ request returns, prefaced by “json=” (this does not appear on the demo web page WRITE box because it is prepended by the textarea box in which it is written.
Demo page usage:
[ol][li]select a metric name, start, and stop times, and click the Read button. The received text will appear in the frame on the right-hand side. If there’s an error it may return an error message, or blank if there’s no data to return.[/li]
[li]copy and paste the returned data into the POST content window, deleting the entries you want to remain unchanged, and changing the data values (first number of each value/time pair) as required. Click on the Write button and a confirmation of the changed data should appear in the right-hand frame.[/li][/ol]
It’s basic, but a whole lot easier that what I used to do to correct the odd error, which was to directly edit the Whisper files… very easy to corrupt the database like that! This approach is much safer since syntax errors should generate error messages and only valid entries are changed.
I would be very pleased to hear/see if anyone takes up the challenge of making a better front-end for this.