Closed NicoAdrian closed 6 months ago
You also need to use it with github.com/grafana/jsonnet-libs/grizzly to wrap the grafonnet object in a k8s style object.
Thanks for the swift answer.
I just installed it using jb install github.com/grafana/jsonnet-libs/grizzly
. Is it the right way ?
My dashboard.jsonnet
looks like this:
local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
grafonnet.dashboard.new('My Dashboard')
Can you please provide me an example of how to "wrap" the grafonnet object ?
I did this:
local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local grizzly = import 'grizzly/grizzly.libsonnet';
grizzly.fromPrometheusKsonnet(grafonnet.dashboard.new('My Dashboard'))
But when running this command jsonnet -J vendor dashboard.jsonnet
I get this error:
RUNTIME ERROR: Field does not exist: grafanaDashboards
vendor/grizzly/grizzly.libsonnet:11:30-52 thunk from <object <anonymous>>
vendor/grizzly/grafana.libsonnet:14:31-41 thunk from <function <anonymous>>
<std>:1539:24-25 thunk from <function <anonymous>>
<std>:1539:5-33 function <anonymous>
vendor/grizzly/grafana.libsonnet:14:14-42 function <anonymous>
vendor/grizzly/grafana.libsonnet:(7:33)-(15:4)
vendor/grizzly/grafana.libsonnet:(7:33)-(15:4)
vendor/grizzly/grizzly.libsonnet:11:14-70 object <anonymous>
Field "grafana"
During manifestation
I managed to make it work with this:
local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local grizzly = import 'grizzly/grizzly.libsonnet';
grizzly.dashboard.new("Test", g.dashboard.new('My Dashboard'))
For future readers, some time ago I created minimal working example of Grafonnet in combination with Grizzly, which is available here: https://github.com/joanlopez/grafonnet-example
@joanlopez Maybe you can help me on this one:
With the previous grafonnet version grafonnet-lib, I could specify the grafana folder I wanted my dashboards to be pushed to with grizzly.
{
grafanaDashboardFolder:: 'SomeFolder',
grafanaDashboards:: {
foo: import 'myDashboard.libsonnet',
}
}
Now, with the new Grafonnet here, I can't find a way to do the same thing. What am I missing ?
As far as I can tell, it looks like grafanaDashboardFolder
is still being used in combination with grafanaDashboards
(see https://github.com/grafana/grizzly/blob/main/pkg/grizzly/grizzly.jsonnet#L32), but that's Grizzly bits, so I'm not sure how the interoperability between that and the new Grafonnet might have been affected.
I think that's a better question for either @Duologic or @malcolmholmes. Sorry for not being to shed some light! 🙏🏻
You set a folder
metadata element on your k8s style object. Perhaps there is also a withFolder
function in the grizzly lib?
Can grafonnet be used with grizzly ? I can an error when trying to use the
grr preview
command:FATA[0000] recursion did not resolve in a valid Kubernetes object. In path '.' found key 'schemaVersion' of type 'float64' instead.
Any idea ?