mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 16:21:34 +01:00
grafana: Avoid dashboard patching by using victoriametrics's prometheus compatibility
This commit is contained in:
parent
14956c6712
commit
8a45686da7
3 changed files with 34 additions and 41 deletions
|
|
@ -58,6 +58,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "grafana.${tailscaleDomain}";
|
domain = "grafana.${tailscaleDomain}";
|
||||||
datasources = {
|
datasources = {
|
||||||
|
prometheus.enable = true;
|
||||||
victoriametrics.enable = true;
|
victoriametrics.enable = true;
|
||||||
victorialogs.enable = true;
|
victorialogs.enable = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ in
|
||||||
default = 3000;
|
default = 3000;
|
||||||
};
|
};
|
||||||
datasources = {
|
datasources = {
|
||||||
|
prometheus = {
|
||||||
|
enable = lib.mkEnableOption "";
|
||||||
|
url = lib.mkOption {
|
||||||
|
type = lib.types.nonEmptyStr;
|
||||||
|
default = "https://metrics.${config.custom.services.tailscale.domain}";
|
||||||
|
};
|
||||||
|
};
|
||||||
victoriametrics = {
|
victoriametrics = {
|
||||||
enable = lib.mkEnableOption "";
|
enable = lib.mkEnableOption "";
|
||||||
url = lib.mkOption {
|
url = lib.mkOption {
|
||||||
|
|
@ -69,34 +76,36 @@ in
|
||||||
dashboards.settings = {
|
dashboards.settings = {
|
||||||
# TODO: Uncomment when upgrading to 25.11
|
# TODO: Uncomment when upgrading to 25.11
|
||||||
# prune = true;
|
# prune = true;
|
||||||
providers = [
|
providers = lib.singleton {
|
||||||
{
|
|
||||||
name = "Dashboards";
|
name = "Dashboards";
|
||||||
disableDeletion = true;
|
options.path = "/etc/grafana-dashboards";
|
||||||
options = {
|
|
||||||
path = "/etc/grafana-dashboards";
|
|
||||||
foldersFromFilesStructure = true;
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
datasources.settings = {
|
datasources.settings = {
|
||||||
# TODO: Uncomment when upgrading to 25.11
|
# TODO: Uncomment when upgrading to 25.11
|
||||||
# prune = true;
|
# prune = true;
|
||||||
datasources =
|
datasources =
|
||||||
(lib.optional cfg.datasources.victoriametrics.enable {
|
(lib.optional cfg.datasources.prometheus.enable {
|
||||||
|
name = "Prometheus";
|
||||||
|
type = "prometheus";
|
||||||
|
inherit (cfg.datasources.prometheus) url;
|
||||||
|
isDefault = true;
|
||||||
|
jsonData = {
|
||||||
|
prometheusType = "Prometheus";
|
||||||
|
prometheusVersion = "2.50.0";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
++ (lib.optional cfg.datasources.victoriametrics.enable {
|
||||||
name = "VictoriaMetrics";
|
name = "VictoriaMetrics";
|
||||||
type = "victoriametrics-metrics-datasource";
|
type = "victoriametrics-metrics-datasource";
|
||||||
access = "proxy";
|
inherit (cfg.datasources.victoriametrics) url;
|
||||||
url = "https://metrics.${config.custom.services.tailscale.domain}";
|
isDefault = false;
|
||||||
isDefault = true;
|
|
||||||
})
|
})
|
||||||
++ (lib.optional cfg.datasources.victorialogs.enable {
|
++ (lib.optional cfg.datasources.victorialogs.enable {
|
||||||
name = "VictoriaLogs";
|
name = "VictoriaLogs";
|
||||||
type = "victoriametrics-logs-datasource";
|
type = "victoriametrics-logs-datasource";
|
||||||
access = "proxy";
|
inherit (cfg.datasources.victorialogs) url;
|
||||||
url = "https://logs.${config.custom.services.tailscale.domain}";
|
|
||||||
isDefault = false;
|
isDefault = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -108,19 +117,13 @@ in
|
||||||
++ (lib.optional cfg.datasources.victorialogs.enable victoriametrics-logs-datasource);
|
++ (lib.optional cfg.datasources.victorialogs.enable victoriametrics-logs-datasource);
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."grafana-dashboards/node-exporter-full.json".source =
|
environment.etc."grafana-dashboards/node-exporter-full.json" = {
|
||||||
lib.mkIf cfg.dashboards.node-exporter-full.enable
|
enable = cfg.dashboards.node-exporter-full.enable;
|
||||||
(
|
source = pkgs.fetchurl {
|
||||||
pkgs.fetchurl {
|
|
||||||
name = "node-exporter-full.json";
|
name = "node-exporter-full.json";
|
||||||
url = "https://grafana.com/api/dashboards/1860/revisions/41/download";
|
url = "https://grafana.com/api/dashboards/1860/revisions/41/download";
|
||||||
hash = "sha256-A6/4QjcMzkry68fSPwNdHq8i6SGwaKwZXVKDZB5h71A=";
|
hash = "sha256-EywgxEayjwNIGDvSmA/S56Ld49qrTSbIYFpeEXBJlTs=";
|
||||||
downloadToTemp = true;
|
};
|
||||||
postFetch = ''
|
};
|
||||||
patch $downloadedFile < ${./patches/node-exporter-full.patch}
|
|
||||||
mv $downloadedFile $out
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
--- v1.json 2025-06-27 15:13:02.187282992 -0600
|
|
||||||
+++ v2.json 2025-06-27 15:12:49.094889325 -0600
|
|
||||||
@@ -16015,7 +16015,7 @@
|
|
||||||
"label": "Datasource",
|
|
||||||
"name": "DS_PROMETHEUS",
|
|
||||||
"options": [],
|
|
||||||
- "query": "prometheus",
|
|
||||||
+ "query": "victoriametrics-metrics-datasource",
|
|
||||||
"refresh": 1,
|
|
||||||
"regex": "",
|
|
||||||
"type": "datasource"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue