Closed aliaksei-karneyeu closed 3 years ago
Hi! First, in your main file, you'll need to call addPanel
to get the show_metrics
return value in the right place.
...
.addRow(
grafana.row.new(title='General metrics')
.addPanel(
common_metrics.show_metrics('My title', 'sum(rate(...))')
)
)
Then define show_metrics
like this:
...
{
show_metrics(title, expr)::
grafana.graphPanel.new(title)
.addTarget(
grafana.prometheus.target(expr)
),
}
Functions defined with local
are not accessible outside of the file they're defined in.
Thank you. It works
Hello guys, I'm working with grafonnet for some and and quiet like it, thank you for your work.
Currently I'm working on case, where I need to have common set of panels in different dashboards. So I created file
common_panels.jibsonnet
:and on main file I would like to call it with needed parameters like:
Unfortunatelly I couldn't make it work. One thing that could work - to create json objects in the function, so file
common_panels.jibsonnet
would be muuuuuch longer then main file.