grafana / grafonnet

Jsonnet library for generating Grafana dashboards.
https://grafana.github.io/grafonnet/
Apache License 2.0
320 stars 18 forks source link

Build example runtimeDashboard fails with row in g.util.grid.makeGrid #211

Closed DontWanna1 closed 2 weeks ago

DontWanna1 commented 2 weeks ago

Hi, I have noticed a problem when trying the examples:

I execute the following command with v11 and v10.4: jsonnet -J vendor main.libsonnet Example: https://github.com/grafana/grafonnet/tree/main/examples/runtimeDashboard

This will fail:

+ g.dashboard.withPanels(
  g.util.grid.makeGrid([
    row.new('Process'),
    ], panelWidth=8)    

This will succeed:

+ g.dashboard.withPanels(
  g.util.grid.makeGrid([
      panels.timeSeries.cpuUsage('CPU Usage', queries.cpuUsage),
    ], panelWidth=8)    
)

Error log:

RUNTIME ERROR: field does not exist: get
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/././panel.libsonnet:112:22-29     object <anonymous>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/././panel.libsonnet:220:18-33     function <func>
        std.jsonnet:789:24-47   thunk <running>
        std.jsonnet:789:9-57    function <aux>
        std.jsonnet:789:9-57    function <aux>
        std.jsonnet:790:5-28    function <anonymous>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/././panel.libsonnet:(216:5)-(228:6)       function <anonymous>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/./grid.libsonnet:74:25-101        thunk <uncollapsed>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/./grid.libsonnet:76:45-56 thunk <panels>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/custom/util/././panel.libsonnet:250:31-37
        ...
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/clean/../custom/./util/./panel.libsonnet:57:12-18     thunk <panels>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/clean/../custom/./util/./panel.libsonnet:54:9-15      thunk <arr>
        std.jsonnet:790:15-18   thunk <arr>
        std.jsonnet:786:28-31
        std.jsonnet:786:17-32   function <aux>
        std.jsonnet:790:5-28    function <anonymous>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/clean/../custom/./util/./panel.libsonnet:(21:7)-(56:8)        function <infunc>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/clean/../custom/./util/./panel.libsonnet:57:5-19      function <anonymous>
        vendor/github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/clean/../custom/dashboard.libsonnet:27:12-48  object <anonymous>
        During manifestation
malcolmholmes commented 2 weeks ago

According to the Jsonnet Standard Library docs, std.get was introduced in Jsonnet 0.18.0. So make sure you're using Jsonnet >=0.18.0 for this to work.

Closing now. Feel free to reopen if this doesn't solve your issue.