Skip to content
This repository was archived by the owner on Jun 5, 2026. It is now read-only.
This repository was archived by the owner on Jun 5, 2026. It is now read-only.

Grizzly serve grafonnet missing template variables #591

Description

@zabojpetr

Grizzly Version

0.7.1

Expected Behavior

Hi,

I generate dashboard with grafonnet and I cannot see template variables in Grizzly (I run it in docer). When I generate json and insert it to grafana I can see the variables there. In grizzly I need to wrap the grafonnet dashboard with grizzly wrapper, but I expect that the output will be the same - variables will be there.

Actual Behavior

Template variables are missing in grizzly serve when I use grafonnet for dashboard generating.

Steps to Reproduce

Install packages

  1. jb install github.com/grafana/grafonnet/gen/grafonnet-latest@main
  2. jb install github.com/grafana/grafonnet/gen/grafonnet-v11.2.0@main
  3. jb install github.com/grafana/jsonnet-libs/grizzly@master
// grr.jsonnet
local grr = import 'github.com/grafana/jsonnet-libs/grizzly/grizzly.libsonnet';
local myLib = import './online.jsonnet';

{
  folders: [],
  dashboards: [
    grr.dashboard.new('Online device - new - grafonnet', myLib)
  ]
}
// online.jsonnet
local g = import 'github.com/grafana/grafonnet/gen/grafonnet-v11.2.0/main.libsonnet';
local tdp_datasource = {
    type: "postgres",
    uid: "postgres_db_id"
};

g.dashboard.new('Online device - new - grafonnet')
+ g.dashboard.withUid("online-device-new-grafonnet")
+ g.dashboard.withTagsMixin("generated")

+ g.dashboard.withVariablesMixin(
    g.dashboard.variable.constant.new("schema", "public")
)
+ g.dashboard.withVariablesMixin(
    g.dashboard.variable.constant.new("prefix", "/")
)
+ g.dashboard.withVariablesMixin(
    g.dashboard.variable.query.new(
        "deviceid",  
        |||
            SELECT * FROM ${schema}.fancy_device_table
        |||
    )
    + g.dashboard.variable.query.generalOptions.withLabel("Device")
    + g.dashboard.variable.query.withDatasource(tdp_datasource.type, tdp_datasource.uid)
)

Then run command grr serve -w -S 'jsonnet /data/grr.jsonnet -J /data/vendor' -l debug /data

I want to try serve only the generated JSON, but when I try grr serve /data/online.json -l debug I get error

parse error in '/data/online.json': found invalid object (at .): errors parsing resource: kind missing, metadata missing, spec missing schemaVersion: 39 tags: - generated templating: list: - hide: 2 name: schema query: tmcz type: constant - hide: 2 name: prefix query: / type: constant - datasource: type: postgres uid: postgres_db_id label: Device name: deviceid query: "SELECT * FROM ${schema}.fancy_device_table\r\n" type: query time: from: now-6h to: now timezone: utc title: Online device - new - grafonnet uid: online-device-new-grafonnet 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions