You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this can be part of this project, I just want to share this somewhere.
It can be quiet cumbersome to check for things like unique UID and titles, so I integrated the logic in Jsonnet, and then generating the deployment simply fails if the condition are not met.
local folderDashboards = {
// ExampleAWS:import'aws/folder.libsonnet',
Datastores:import'datastores/folder.libsonnet',
Kubernetes:import'kubernetes/folder.libsonnet',
myServices:import'myServices/folder.libsonnet',
System:import'system/folder.libsonnet',
};
local titles = [
folderDashboards[folder][filename].title
for folder instd.objectFields(folderDashboards)
for filename instd.objectFields(folderDashboards[folder])
];
local filenames = [
filename
for folder instd.objectFields(folderDashboards)
for filename instd.objectFields(folderDashboards[folder])
];
local isTitleUnique(title) =
ifstd.count(titles, title) > 1thenerror'Title "%s" is used more than once' % [title]
elsetrue;
local isFilenameUnique(filename) = // Means UID will be uniqueifstd.count(filenames, filename) > 1thenerror'Filename "%s" is used more than once' % [filename]
elsetrue;
{
[folder]: {
[filename]: folderDashboards[folder][filename] {
uid:// Checks need to be included into a non-hidden field// else they would never be evaluatedif isFilenameUnique(filename) && isTitleUnique(self.title) then// We could hash folder+filename, but this would break// the dashboard URL if it is moved
std.md5(filename),
}
for filename instd.objectFields(folderDashboards[folder])
}
for folder instd.objectFields(folderDashboards)
}
Every dashboard needs a UID, so the checks are called while setting it.
and then, pass the output to _config.grafana.folderDashboards.
The text was updated successfully, but these errors were encountered:
I think this is really amazing yes! I feel maybe it could be more suited as part of the grafonnet project, but if they don't want to accept this I think I'd be willing to have it here! :)
Not sure if this can be part of this project, I just want to share this somewhere.
It can be quiet cumbersome to check for things like unique UID and titles, so I integrated the logic in Jsonnet, and then generating the deployment simply fails if the condition are not met.
Every dashboard needs a UID, so the checks are called while setting it.
and then, pass the output to
_config.grafana.folderDashboards
.The text was updated successfully, but these errors were encountered: