Rewrite values in the query #121
-
|
During the process for import/export dashboard through the environments, sometime i do need rewrite some parts inside the query. Unfortunately they couldn't be covered by regular expressions, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
|
The Regex is intended primarily for determining which datasource to use and filtering purposes. There's nothing in the too currently that supports rewrites. I'd like to add support for plugins though it was initially intended mainly to provide more flexibility for input and output destination. I wrote this bit of code a few years back not sure how useful it would be but it deals with manipulating the data a bit, query and such. Some of it is very custom to netsage project, other might be reusable. https://github.com/netsage-project/netsage-grafana-configs/tree/master/templates I will say that regex manipulation and such is really error prone. If you really want to control how a dashboard looks you might look at: https://grafana.com/blog/2022/12/06/a-complete-guide-to-managing-grafana-as-code-tools-tips-and-tricks/. Downside it's a 1 way route. Aka can't easily import the changes someone made on a dashboard back into code. GDG and similar tool rely on the API which is great for imports/exports but modifying the generated JSON isn't always very easy to do. |
Beta Was this translation helpful? Give feedback.
-
|
TLDR: I don't mind adding this feature but I will say that this might be something I'd rather support via plugins and might take a while before we're at that point. |
Beta Was this translation helpful? Give feedback.
-
|
@romankydybets I may revisit this but I imagine we'll need to have some embedded scripting language to support this. I've used some JS engine with Go, though I need to explore others. I'd prefer golang but not sure if it has enough adoption to really make sense. Anyways, this might be getting revisited. |
Beta Was this translation helpful? Give feedback.
Sure thing.
Let me know if there's any ambiguity: https://software.es.net/gdg/docs/templating/usage-guide/ though I will say this is a one way workflow. Template -> dashboards, you can't really pull changes from a live dashboard, pop them into a template and have it update all dashboards again. (Well, not without dealing with essentially the equivalent of a merge conflict)