Skip to content

Grafana folders support #72

@SebastianIoanPop

Description

@SebastianIoanPop

Hello, is there a way currently to make use of the grafana folders feature?

See:
https://grafana.com/docs/reference/dashboard_folders/
and
https://grafana.com/docs/administration/provisioning/#dashboards

I've tried a few hacks to make this work, as currently providing the configuration for dashboards with a composite path currently is not supported.

As the only limitation seems to be creating multiple folders within the container and separating the dashboards into the appropriate folders, I've tried the following:

local volumeMounts =
        [
          storageVolumeMount,
          datasourcesVolumeMount,
          dashboardsVolumeMount,
        ] +
        [
          local splitName = std.splitLimit(name, '/', 1);
          local folderName = if std.length(splitName) > 1 then splitName[0] else "0";
          local dashboardName = if std.length(splitName) < 2 then std.strReplace(splitName[0], '.json', '') else std.strReplace(splitName[1], '.json', '');
          containerVolumeMount.new('grafana-dashboard-' + dashboardName, '/grafana-dashboard-definitions/' + folderName + '/' + dashboardName),
          for name in std.objectFields($._config.grafana.dashboards)
        ] +
        if std.length($._config.grafana.config) > 0 then [configVolumeMount] else [];

(apply this change anywhere where it's relevant)
Which allowed the following convention to be used:

grafanaDashboards+:: {
    'folder/example.json': (import 'configs/dashboards/example.json')
}

However due to changing the core vendor file, it would make keeping up to date difficult so I would prefer it if I didn't have extra maintenance should this repo be updated.

I've also faced multiple problems related to volume mounts while doing that.

My approach should be a non-breaking change, however I don't fully understand jsonnet, grafana or kubernetes so there may be implications I'm not aware of or a better and cleaner way of doing it.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions