Interfaces for modelJson

I’m writing a backend datasource plugin in go and there is a lot of json being passed around. It’s easy enough to do this:

var model map[string]interface{}
json.Unmarshal([]byte(tsdbReq.Queries[0].ModelJson), &model)

but it seems like there must be actual models somewhere for either that, or at least for the more detailed objects once you get past queryType. I wrote a findMetrics() method but I don’t really want to pass it unstructured json. What I’d prefer to know is what are the interface for the actual, expected object; then I can marshal to the correct thing and limit the amount of time I spend without type safety.

Can anybody point me to these interfaces, if they exist?


Maybe what I’m looking for doesn’t actually exist. Perhaps the contract is really between my query editor and my backend, and Grafana simply doesn’t care, it just passes opaque blobs of json from one to another with no interpretation.

That is currently the case. There’s been some talk about formalizing this since that would allow for some manipulation that Grafana cannot really do today in any reasonable way.