我能够生成面板 JSON 来配置 Grafana 仪表板,如下所示:
jsonnet -J ~/grafana/grafonnet-lib mydash.jsonnet > mydash.json
Run Code Online (Sandbox Code Playgroud)
不过,我喜欢在 Grafana 本身中操作和编辑生成的仪表板。
我绝对感到困惑和沮丧的是,一旦我通过调整 Grafana 的设置等方式在 Grafana 中进行了 UI 更改……如何将其返回到Jsonnet 中?现在对我来说这是一次超级尴尬的开发经历。我导出面板 JSON 并在单独的窗口中打开源 Jsonnet,并认真尝试移植我的更改。
当您在 JSON 中可能遇到以下情况时,这尤其令人痛苦:
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": true,
"lineColor": "rgb(31, 120, 193)",
"show": true
},
Run Code Online (Sandbox Code Playgroud)
您需要手动转换为 Jsonnet/Graffonet-lib:
sparklineShow=true,
sparklineFull=true,
colorBackground=true,
Run Code Online (Sandbox Code Playgroud)
我是否缺少技巧或工作流程?
您必须编辑 mydash.jsonnet 并在其中添加所需的属性。据我所知,目前还没有自动方法可以从 grafana-json 转换回 grafonnet。有时找到合适的属性有点痛苦。
您正在寻找的属性在这里: https: //github.com/grafana/grafonnet-lib/blob/master/grafonnet/singlestat.libsonnet#L44
像这样的东西应该有效:
本地grafana =导入'grafonnet/grafana.libsonnet'; grafana.仪表板.new( “迷你图示例” ) .addPanel( grafana.singlestat.new( '正常运行时间', 格式='s', 跨度=4, valueName='当前', SparklineFillColor='rgba(31, 118, 189, 0.18)', 迷你图全=真, SparklineLineColor='rgb(31, 120, 193)', 火花线显示=真, ) .addTarget( grafana.prometheus.target( '时间()', ) ), 网格位置={ x:0, y:0, 宽:24, 小时:3, } )
归档时间: |
|
查看次数: |
2163 次 |
最近记录: |