How do I convert my libsonnet files into jsonnet files and then plot them in Grafana? I am using the repo: grafonnet-lib. Here I want to execute the libsonnet files in grafonnet, but when I execute a file, for example: dashboard.libsonnet, in vscode I get this: { } FYI: I am using a Windows 10 machine

What should I do in order to execute a libsonnet file and see something in Grafana?

Also, where are the libsonnet libraries and how do I work with them? I think I dont have to install any libraries, right?

1 Answer

Don't execute the libsonnet itself, it's a library. Import and call the grafonnet functions from a separate jsonnet file. For grafonnet, there are tons of examples.

Straight from the grafana/grafonnet-lib/examples page... (hint: this goes in a separate .jsonnet file, not in grafana.libsonnet)

local grafana = import 'grafonnet/grafana.libsonnet'; local dashboard = grafana.dashboard; local row = grafana.row; 
dashboard.new( 'JVM', schemaVersion=16, tags=['java'], ) 

Look into jb (jsonnet builder) for managing the libsonnet called by in jsonnet.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.