【问题标题】:To use Gitlab Dashboards - How to use grafonnet with jsonnet to produce a json file that I can use with Grafana使用 Gitlab 仪表板 - 如何将 grafonnet 与 jsonnet 一起使用以生成我可以与 Grafana 一起使用的 json 文件
【发布时间】:2021-10-08 02:22:32
【问题描述】:

谁能告诉我如何在 grafonnet 中使用 jsonnet 文件?喜欢新手一步一步吗?

我想在本地 Grafana 环境中使用 GitLab 仪表板 - https://gitlab.com/gitlab-com/runbooks/-/tree/master/dashboards

到目前为止我发现的唯一有用的教程在这里 - https://hodari.be/posts/2020_06_27_grafana_and_grafonnet_dashboards/

我假设 jsonnet 会吐出我可以导入到我的 Grafana 中的 json。

所以我下载了 jsonnet 文件,我假设让我使用 kubernetes 版本的仪表板并尝试在其上运行 jsonnet -

$ jsonnet kubernetes_version.dashboard.jsonnet
RUNTIME ERROR: couldn't open import "grafana/basic.libsonnet": no match locally or in the Jsonnet library paths.
    kubernetes_version.dashboard.jsonnet:8:15-47    thunk <basic>
    kubernetes_version.dashboard.jsonnet:90:1-6

我在网上搜索了 grafana/basic.libsonnet,但找不到任何东西。

有人可以逐步说明将 jsonnet 文件转换为可用 json 所需的操作 - 还是我理解完全错误??

我确实查看了 jsonnet 和 grafonnet 主页,但对我没有任何帮助。

我在哪里获取并放置 grafana/basic.libsonnet?

非常感谢任何帮助!

【问题讨论】:

    标签: gitlab grafana jsonnet


    【解决方案1】:

    您需要将jsonnet-bundler 指向项目自己的jsonnetfile.json 文件所在的文件夹,以使其下载更多依赖项。 然后指定所需的vendor/-ed 文件夹位置,下面运行正常,向标准输出显示 JSON 仪表板:

    $ jb init
    
    $ jb install gitlab.com/gitlab-com/runbooks
    GET https://github.com/grafana/grafonnet-lib/archive/3082bfca110166cd69533fa3c0875fdb1b68c329.tar.gz 200
    GET https://github.com/grafana/jsonnet-libs/archive/8df6a4ff1623781260c3236761c2ebe837958b3f.tar.gz 200
    GET https://github.com/jsonnet-libs/xtd/archive/e9ffe67357685703df80703844885da91d59296e.tar.gz 200
    GET https://github.com/kubernetes-monitoring/kubernetes-mixin/archive/dd0f1df93645a917b32c0fa7bfdc331730dc64a2.tar.gz 200
    GET https://github.com/yugui/jsonnetunit/archive/6927c58cae7624a00f368b977ccc477d4f74071f.tar.gz 200
    
    $ jsonnet -J vendor -J vendor/gitlab.com/gitlab-com/runbooks/libsonnet vendor/gitlab.com/gitlab-com/runbooks/dashboards/general/kubernetes_version.dashboard.jsonnet
    [JSON output ...]
    

    --jjo

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 2018-07-08
      • 1970-01-01
      • 1970-01-01
      • 2017-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多