summaryrefslogtreecommitdiff
path: root/nixos/hosts/tente/grafana.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/hosts/tente/grafana.nix')
-rw-r--r--nixos/hosts/tente/grafana.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/nixos/hosts/tente/grafana.nix b/nixos/hosts/tente/grafana.nix
new file mode 100644
index 0000000..e6fb7af
--- /dev/null
+++ b/nixos/hosts/tente/grafana.nix
@@ -0,0 +1,63 @@
+{ config, lib, pkgs, ... }:
+
+let
+ cfg = config.grafana;
+in
+{
+ options.grafana = {
+ port = lib.mkOption {
+ type = lib.types.int;
+ };
+ matrixForwarderPort = lib.mkOption {
+ type = lib.types.int;
+ };
+ prometheusSqlExporterPort = lib.mkOption {
+ type = lib.types.int;
+ };
+ matrixServerUrl = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+
+ imports = [
+ <top/shared/prometheus-sql-exporter/service.nix>
+ <top/shared/grafana-matrix-forwarder/service.nix>
+ ];
+
+ config = {
+ age.secrets.grafana-matrix-forwarder-env.file = <top/secrets/grafana-matrix-forwarder-env.age>;
+
+ services.grafana = {
+ enable = true;
+ settings = {
+ server = {
+ http_addr = "0.0.0.0";
+ http_port = cfg.port;
+ };
+ };
+
+ provision = {
+ enable = true;
+ datasources.settings.datasources = [
+ {
+ name = "Prometheus Tente";
+ type = "prometheus";
+ url = "http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}";
+ }
+ {
+ name = "Loki Tente";
+ type = "loki";
+ access = "proxy";
+ url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
+ }
+ ];
+ };
+ };
+ services.grafana-matrix-forwarder = {
+ enable = true;
+ port = cfg.matrixForwarderPort;
+ homeserver = cfg.matrixServerUrl;
+ environmentFile = config.age.secrets.grafana-matrix-forwarder-env.path;
+ };
+ };
+}