github.com/clambin/simplejson/v6 (go): Package simplejson provides a Go implementation for Grafana's SimpleJSON datasource: https://grafana.com/grafana/plugins/grafana-simple-json-datasource  A simplejson server supports one or more handlers.  Each handler can support multiple query targets,which can be either timeseries or table query. A handler may support tag key/value pairs, which can be passed to the query to adapt its behaviour (e.g. filtering what data should be returned) through 'ad hoc filters'. Finally, a handler can support annotations, i.e. a set of timestamps with associated text.  simplejson.New() creates a SimpleJSON server.  The server is implemented as an http router, compatible with net/http:  This starts a server, listening on port 8080, with one target "my-target", served by myHandler.  A handler serves incoming requests from Grafana, e.g. queries, requests for annotations or tag. The Handler interface contains all functions a handler needs to implement. It contains only one function (Endpoints). This function returns the Grafana SimpleJSON endpoints that the handler supports. Those can be:  Here's an example of a handler that supports timeseries queries:  SimpleJSON supports two types of query responses: timeseries responses and table responses.  Timeseries queries return values as a list of timestamp/value tuples. Here's an example of a timeseries query handler:  Table Queries, on the other hand, return data organized in columns and rows.  Each column needs to have the same number of rows:  The /annotations endpoint returns Annotations:  NOTE: this is only called when using the SimpleJSON datasource. simPod/GrafanaJsonDatasource does not use the /annotations endpoint. Instead, it will call a regular /query and allows to configure its response as annotations instead.  The /tag-keys and /tag-values endpoints return supported keys and key values respectively for your data source. A Grafana dashboard can then be confirmed to show those keys and its possible values as a filter.  The following sets up a key & key value handler:  When the dashboard performs a query with a tag selected, that tag & value will be added in the request's AdHocFilters.  When provided with the WithQueryMetrics option, simplejson exports two Prometheus metrics for performance analytics:  The underlying http router uses PrometheusMetrics, which exports its own set of metrics. See WithHTTPMetrics for details.  For information on query arguments and tags, refer to the documentation for those data structures.
Keywords: grafana|simplejson