This doesn’t answer your question, but when I was trying to setup grafana on NixOS, I had a lot of trouble getting the NixOS grafana module to do exactly what I wanted. This is about what I ended up with:
{ config, pkgs, lib, ... }:
{
imports = [];
services.grafana = {
enable = true;
settings.server = {
domain = "my-domain.com";
http_addr = "0.0.0.0";
http_port = 3000;
};
provision = {
enable = true;
datasources = {
settings = {
datasources = [
{
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "http://127.0.0.1:${toString config.services.prometheus.port}";
isDefault = true;
}
{
name = "Loki";
type = "loki";
access = "proxy";
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
}
];
};
};
dashboards = {
settings = {
providers = [
{
name = "My Dashboards";
options.path = "/etc/grafana-dashboards";
}
];
};
};
};
};
environment.etc = {
"grafana-dashboards/node-exporter-full_rev30.json" = {
source = ./grafana-dashboards/node-exporter-full_rev30.json;
group = "grafana";
user = "grafana";
};
};
}
You can see that I setup Grafana to look at the /etc/grafana-dashboards
directory for dashboards, and then I just create files in that directory with environment.etc
.
Hopefully this either gets you started, or someone else will be able to come along and answer your actual question.
(Also, I imagine you already know this, but just renaming a .json
file to .yaml
should always work, since YAML is a super-set of JSON. Any valid JSON file is by definition also a valid YAML file.)