From ba40cc49eb3d5b468ccd9fab3411cc2d60f9fdf9 Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Thu, 14 Aug 2025 15:18:52 +0530 Subject: [PATCH] feat: Added grafana other devices --- home/apps/zed.nix | 29 +- home/default.nix | 25 +- modules/default.nix | 3 +- neovim/default.nix | 240 ++++--- nixos/mirai/services/grafana.nix | 58 +- .../services/grafana/services-dashboard.json | 654 ------------------ nixos/ryu/services/default.nix | 4 +- nixos/ryu/services/monitoring.nix | 42 ++ nixos/tsuba/services/default.nix | 4 +- nixos/tsuba/services/monitoring.nix | 42 ++ 10 files changed, 298 insertions(+), 803 deletions(-) delete mode 100644 nixos/mirai/services/grafana/services-dashboard.json create mode 100644 nixos/ryu/services/monitoring.nix create mode 100644 nixos/tsuba/services/monitoring.nix diff --git a/home/apps/zed.nix b/home/apps/zed.nix index a8c09a77..19b20d88 100644 --- a/home/apps/zed.nix +++ b/home/apps/zed.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -}: { +}: +{ home.packages = with pkgs; [ nixd nil @@ -43,6 +44,13 @@ reveal_target = "center"; } ]; + "space f g" = [ + "task::Spawn" + { + task_name = "file_manager"; + reveal_target = "center"; + } + ]; }; } { @@ -119,21 +127,34 @@ userTasks = [ { label = "file_finder"; - command = "${lib.getExe pkgs.zed-editor} \"$(tv files)\""; + command = "${lib.getExe pkgs.zed-editor} \"$(${lib.getExe pkgs.television} files)\""; hide = "always"; allow_concurrent_runs = true; use_new_terminal = true; } { label = "live_grep"; - command = "tv text | read -alz res; and ${lib.getExe pkgs.zed-editor} $res"; + command = "${lib.getExe pkgs.television} text | read -alz res; and ${lib.getExe pkgs.zed-editor} $res"; hide = "always"; allow_concurrent_runs = false; use_new_terminal = false; shell = { with_arguments = { program = "fish"; - args = ["--no-config"]; + args = [ "--no-config" ]; + }; + }; + } + { + label = "file_manager"; + command = "${lib.getExe pkgs.yazi} --chooser-file /dev/stdout | read -alz res;and ${lib.getExe pkgs.zed-editor} $res"; + hide = "always"; + allow_concurrent_runs = false; + use_new_terminal = false; + shell = { + with_arguments = { + program = "fish"; + args = [ "--no-config" ]; }; }; } diff --git a/home/default.nix b/home/default.nix index c7347469..c70ffd8e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -5,7 +5,8 @@ lib, device, ... -}: { +}: +{ imports = [ inputs.nix-index-database.homeModules.nix-index ../modules @@ -23,7 +24,9 @@ }; programs = { - home-manager = {enable = true;}; + home-manager = { + enable = true; + }; }; fonts.fontconfig.enable = true; @@ -31,16 +34,12 @@ home = { username = device.user; homeDirectory = - if device.isDarwin - then lib.mkForce "/Users/${device.user}" - else lib.mkForce "/home/${device.user}"; + if device.isDarwin then lib.mkForce "/Users/${device.user}" else lib.mkForce "/home/${device.user}"; file = { ".config/fish/themes".source = pkgs.catppuccinThemes.fish + "/themes"; ".cargo/config.toml".text = - /* - toml - */ + # toml '' [alias] lldb = ["with", "rust-lldb", "--"] @@ -61,12 +60,12 @@ EDITOR = "nvim"; SHELL = "${pkgs.bash}/bin/bash"; CARGO_TARGET_DIR = "${config.xdg.cacheHome}/cargo/target"; - BROWSER = - if device.isDarwin - then "open" - else "xdg-open"; + BROWSER = if device.isDarwin then "open" else "xdg-open"; }; - sessionPath = ["${config.home.homeDirectory}/.cargo/bin" "${config.home.homeDirectory}/.local/bin"]; + sessionPath = [ + "${config.home.homeDirectory}/.cargo/bin" + "${config.home.homeDirectory}/.local/bin" + ]; stateVersion = "23.11"; }; diff --git a/modules/default.nix b/modules/default.nix index 10947807..8a1c624b 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -}: { +}: +{ imports = [ ./goread.nix ./hyprpaper.nix diff --git a/neovim/default.nix b/neovim/default.nix index d4023243..7d6275cd 100644 --- a/neovim/default.nix +++ b/neovim/default.nix @@ -2,29 +2,40 @@ pkgs, # config, ... -}: let - mkMappings = mappings: - [] +}: +let + mkMappings = + mappings: + [ ] ++ (pkgs.lib.optionals (builtins.hasAttr "normal" mappings) (mkMode mappings.normal "n")) ++ (pkgs.lib.optionals (builtins.hasAttr "terminal" mappings) (mkMode mappings.terminal "t")) ++ (pkgs.lib.optionals (builtins.hasAttr "insert" mappings) (mkMode mappings.insert "i")) ++ (pkgs.lib.optionals (builtins.hasAttr "visual" mappings) (mkMode mappings.visual "v")) ++ (pkgs.lib.optionals (builtins.hasAttr "global" mappings) (mkMode mappings.global "")); - mkMode = mappings: mode: - pkgs.lib.mapAttrsToList - (key: value: { + mkMode = + mappings: mode: + pkgs.lib.mapAttrsToList (key: value: { key = key; action = rawLua value; mode = mode; - }) - mappings; - border = ["╭" "─" "╮" "│" "╯" "─" "╰" "│"]; + }) mappings; + border = [ + "╭" + "─" + "╮" + "│" + "╯" + "─" + "╰" + "│" + ]; rawLua = lua: { "__raw" = '' ${lua} ''; }; -in { +in +{ opts = { completeopt = "menu,menuone,popup,noselect"; expandtab = true; @@ -113,7 +124,10 @@ in { autoCmd = [ { - event = ["BufEnter" "BufWinEnter"]; + event = [ + "BufEnter" + "BufWinEnter" + ]; pattern = "*.norg"; command = "set conceallevel=3"; } @@ -123,12 +137,12 @@ in { # command = "nnoremap F :Sqlfmt"; # } { - event = ["BufWinLeave"]; + event = [ "BufWinLeave" ]; pattern = "?*"; command = "mkview!"; } { - event = ["BufWinEnter"]; + event = [ "BufWinEnter" ]; pattern = "?*"; command = "silent! loadview!"; } @@ -148,9 +162,7 @@ in { enable = true; settings = { format_on_save = - /* - lua - */ + # lua '' function(bufnr) if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then @@ -160,10 +172,10 @@ in { end ''; formatters_by_ft = { - d2 = ["d2"]; - sql = ["sleek"]; - toml = ["taplo"]; - nix = ["alejandra"]; + d2 = [ "d2" ]; + sql = [ "sleek" ]; + toml = [ "taplo" ]; + nix = [ "alejandra" ]; }; }; }; @@ -182,27 +194,6 @@ in { }; }; }; - avante = { - enable = true; - settings = { - provider = "copilot"; - providers = { - ollama = { - endpoint = "https://ollama.ryu.darksailor.dev"; - model = "qwen3:30b-a3b"; - }; - }; - input = { - provider = "snacks"; - provider_opts = { - # Additional snacks.input options - title = "Avante Input"; - icon = " "; - }; - }; - }; - }; - snacks.enable = true; yazi = { enable = true; @@ -226,8 +217,8 @@ in { mini = { enable = true; modules = { - ai = {}; - starter = {}; + ai = { }; + starter = { }; }; }; @@ -296,9 +287,7 @@ in { comment = { enable = true; settings.pre_hook = - /* - lua - */ + # lua '' require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() ''; @@ -391,9 +380,7 @@ in { settings = { close_fold_kinds = null; provider_selector = - /* - lua - */ + # lua '' function(bufnr, filetype, buftype) return {'treesitter', 'indent'} @@ -407,30 +394,28 @@ in { server = { on_attach = rawLua - /* - lua - */ - '' - function(client, bufnr) - vim.keymap.set( - "n", - "a", - function() - vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping - -- or vim.lsp.buf.codeAction() if you don't want grouping. - end, - { silent = true, buffer = bufnr } - ) - vim.keymap.set( - "n", - "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions - function() - vim.cmd.RustLsp({'hover', 'actions'}) - end, - { silent = true, buffer = bufnr } - ) - end - ''; + # lua + '' + function(client, bufnr) + vim.keymap.set( + "n", + "a", + function() + vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping + -- or vim.lsp.buf.codeAction() if you don't want grouping. + end, + { silent = true, buffer = bufnr } + ) + vim.keymap.set( + "n", + "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions + function() + vim.cmd.RustLsp({'hover', 'actions'}) + end, + { silent = true, buffer = bufnr } + ) + end + ''; default_settings = { rust-analyzer = { inlayHints = { @@ -462,27 +447,32 @@ in { }; }; }; - dap = let - vscode-lldb = pkgs.vscode-extensions.vadimcn.vscode-lldb; - liblldb = - if pkgs.stdenv.isLinux - then "${vscode-lldb.lldb}/lib/liblldb.so" - else if pkgs.stdenv.isDarwin - then "${vscode-lldb.lldb}/lib/liblldb.dylib" - else null; - codelldb = "${vscode-lldb.adapter}/bin/codelldb"; - in { - autoload_configurations = false; - # adapter = - # /* - # lua - # */ - # '' - # require('rustaceanvim.config').get_codelldb_adapter("${codelldb}", "${liblldb}") - # ''; - }; + dap = + let + vscode-lldb = pkgs.vscode-extensions.vadimcn.vscode-lldb; + liblldb = + if pkgs.stdenv.isLinux then + "${vscode-lldb.lldb}/lib/liblldb.so" + else if pkgs.stdenv.isDarwin then + "${vscode-lldb.lldb}/lib/liblldb.dylib" + else + null; + codelldb = "${vscode-lldb.adapter}/bin/codelldb"; + in + { + autoload_configurations = false; + # adapter = + # /* + # lua + # */ + # '' + # require('rustaceanvim.config').get_codelldb_adapter("${codelldb}", "${liblldb}") + # ''; + }; tools = { - float_win_config = {border = "rounded";}; + float_win_config = { + border = "rounded"; + }; enable_clippy = false; }; }; @@ -526,7 +516,7 @@ in { typeHints.enable = false; }; check = { - features = ["default"]; + features = [ "default" ]; }; files.exclude = [ ".cargo/" @@ -585,26 +575,26 @@ in { settings = { autoEnableSources = true; sources = [ - {name = "buffer";} - {name = "buffer";} - {name = "cmdline";} - {name = "cmp-clippy";} - {name = "cmp-cmdline-history";} - {name = "crates";} - {name = "dap";} + { name = "buffer"; } + { name = "buffer"; } + { name = "cmdline"; } + { name = "cmp-clippy"; } + { name = "cmp-cmdline-history"; } + { name = "crates"; } + { name = "dap"; } # {name = "dictionary";} - {name = "fish";} - {name = "git";} - {name = "luasnip";} - {name = "nvim_lsp";} - {name = "nvim_lua";} - {name = "nvim_lsp_signature_help";} - {name = "nvim_lsp_document_symbol";} - {name = "path";} - {name = "rg";} - {name = "spell";} - {name = "tmux";} - {name = "treesitter";} + { name = "fish"; } + { name = "git"; } + { name = "luasnip"; } + { name = "nvim_lsp"; } + { name = "nvim_lua"; } + { name = "nvim_lsp_signature_help"; } + { name = "nvim_lsp_document_symbol"; } + { name = "path"; } + { name = "rg"; } + { name = "spell"; } + { name = "tmux"; } + { name = "treesitter"; } ]; view = { entries = { @@ -628,9 +618,7 @@ in { "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; }; snippet.expand = - /* - lua - */ + # lua '' function(args) require('luasnip').lsp_expand(args.body) @@ -640,9 +628,7 @@ in { }; }; extraConfigLua = - /* - lua - */ + # lua '' function catcher(callback) do @@ -802,6 +788,18 @@ in { pkgs.tree-sitter-grammars.tree-sitter-norg-meta pkgs.tree-sitter-grammars.tree-sitter-nu ]; - extraLuaPackages = luaPkgs: with luaPkgs; [lua-utils-nvim nvim-nio pathlib-nvim]; - extraPackages = [pkgs.lldb pkgs.taplo pkgs.d2 pkgs.sleek pkgs.graphqurl pkgs.sqls]; + extraLuaPackages = + luaPkgs: with luaPkgs; [ + lua-utils-nvim + nvim-nio + pathlib-nvim + ]; + extraPackages = [ + pkgs.lldb + pkgs.taplo + pkgs.d2 + pkgs.sleek + pkgs.graphqurl + pkgs.sqls + ]; } diff --git a/nixos/mirai/services/grafana.nix b/nixos/mirai/services/grafana.nix index a6d379b7..e44063c1 100644 --- a/nixos/mirai/services/grafana.nix +++ b/nixos/mirai/services/grafana.nix @@ -75,6 +75,26 @@ static_configs = [ { targets = [ "127.0.0.1:9100" ]; + labels = { + device = "mirai"; + type = "server"; + }; + } + { + targets = [ "tsuba:9100" ]; + labels = { + device = "tsuba"; + type = "server"; + arch = "aarch64"; + }; + } + { + targets = [ "ryu:9100" ]; + labels = { + device = "ryu"; + type = "desktop"; + arch = "x86_64"; + }; } ]; } @@ -83,6 +103,26 @@ static_configs = [ { targets = [ "127.0.0.1:9256" ]; + labels = { + device = "mirai"; + type = "server"; + }; + } + { + targets = [ "tsuba:9256" ]; + labels = { + device = "tsuba"; + type = "server"; + arch = "aarch64"; + }; + } + { + targets = [ "ryu:9256" ]; + labels = { + device = "ryu"; + type = "desktop"; + arch = "x86_64"; + }; } ]; } @@ -91,6 +131,9 @@ static_configs = [ { targets = [ "127.0.0.1:9090" ]; + labels = { + device = "mirai"; + }; } ]; } @@ -112,13 +155,13 @@ settings = { access_control = { rules = [ - # { - # domain = "grafana.darksailor.dev"; - # policy = "bypass"; - # resources = [ - # "^/api([/?].*)?$" - # ]; - # } + { + domain = "grafana.darksailor.dev"; + policy = "bypass"; + resources = [ + "^/api([/?].*)?$" + ]; + } { domain = "grafana.darksailor.dev"; policy = "one_factor"; @@ -144,7 +187,6 @@ # Provision dashboards directly environment.etc = { "grafana/dashboards/system-dashboard.json".source = ./grafana/system-dashboard.json; - "grafana/dashboards/services-dashboard.json".source = ./grafana/services-dashboard.json; "grafana/dashboards/processes-dashboard.json".source = ./grafana/processes-dashboard.json; }; } diff --git a/nixos/mirai/services/grafana/services-dashboard.json b/nixos/mirai/services/grafana/services-dashboard.json deleted file mode 100644 index 5ea2eb8e..00000000 --- a/nixos/mirai/services/grafana/services-dashboard.json +++ /dev/null @@ -1,654 +0,0 @@ -{ - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 0, - "id": null, - "links": [], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "vis": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 1, - "options": { - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "node_systemd_unit_state{state=\"active\", name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\"}", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{name}}", - "refId": "A" - } - ], - "title": "Service Status (Active Services)", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [ - { - "options": { - "0": { - "color": "red", - "index": 0, - "text": "Inactive" - }, - "1": { - "color": "green", - "index": 1, - "text": "Active" - } - }, - "type": "value" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 12, - "w": 12, - "x": 0, - "y": 8 - }, - "id": 2, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": ["sum"], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "8.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "node_systemd_unit_state{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\", state=\"active\"}", - "format": "table", - "instant": true, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Service Status Table", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "__name__": true, - "instance": true, - "job": true, - "state": true - }, - "indexByName": {}, - "renameByName": { - "Value": "Status", - "name": "Service" - } - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 12, - "y": 8 - }, - "id": 3, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": ["lastNotNull"], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "count(node_systemd_unit_state{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\", state=\"active\"})", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "Active Services", - "refId": "A" - } - ], - "title": "Total Active Services", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 1 - }, - { - "color": "red", - "value": 5 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 18, - "y": 8 - }, - "id": 4, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": ["lastNotNull"], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "count(node_systemd_unit_state{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\", state=\"failed\"})", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "Failed Services", - "refId": "A" - } - ], - "title": "Failed Services", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "vis": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 14 - }, - "id": 5, - "options": { - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "time() - node_systemd_unit_state_start_time_seconds{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\", state=\"active\"}", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{name}}", - "refId": "A" - } - ], - "title": "Service Uptime", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "vis": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 20 - }, - "id": 6, - "options": { - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "increase(node_systemd_unit_state_restarts_total{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\"}[1h])", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{name}}", - "refId": "A" - } - ], - "title": "Service Restarts (Last Hour)", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 28 - }, - "id": 7, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": ["sum"], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Start Time" - } - ] - }, - "pluginVersion": "8.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "prometheus" - }, - "expr": "node_systemd_unit_state_start_time_seconds{name=~\"(atuin|authelia|caddy|gitea|grafana|immich|navidrome|nextcloud|paperless|prowlarr|seafile|searxng|syncthing|tailscale|lldap|prometheus)\\.service\", state=\"active\"}", - "format": "table", - "instant": true, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Service Start Times", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "__name__": true, - "instance": true, - "job": true, - "state": true - }, - "indexByName": {}, - "renameByName": { - "Value": "Start Time", - "name": "Service" - } - } - }, - { - "id": "convertFieldType", - "options": { - "conversions": [ - { - "destinationType": "time", - "targetField": "Start Time" - } - ], - "fields": {} - } - } - ], - "type": "table" - } - ], - "refresh": "30s", - "schemaVersion": 27, - "style": "dark", - "tags": ["services", "monitoring", "systemd"], - "templating": { - "list": [] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "Services Monitoring Dashboard", - "uid": "services-monitoring", - "version": 1 -} diff --git a/nixos/ryu/services/default.nix b/nixos/ryu/services/default.nix index 7531f66d..b03b1d3e 100644 --- a/nixos/ryu/services/default.nix +++ b/nixos/ryu/services/default.nix @@ -1,4 +1,5 @@ -{...}: { +{ ... }: +{ imports = [ # ./rsyncd.nix # ./sunshine.nix @@ -15,5 +16,6 @@ ./minecraft.nix ./fwupd.nix ./caddy.nix + ./monitoring.nix ]; } diff --git a/nixos/ryu/services/monitoring.nix b/nixos/ryu/services/monitoring.nix new file mode 100644 index 00000000..1be5aa31 --- /dev/null +++ b/nixos/ryu/services/monitoring.nix @@ -0,0 +1,42 @@ +{ ... }: +{ + services = { + prometheus = { + exporters = { + node = { + enable = true; + enabledCollectors = [ + "systemd" + "textfile" + "filesystem" + "loadavg" + "meminfo" + "netdev" + "stat" + "time" + "uname" + "vmstat" + ]; + port = 9100; + }; + process = { + enable = true; + settings.process_names = [ + { + name = "{{.Comm}}"; + cmdline = [ ".*" ]; + } + ]; + }; + }; + }; + }; + + # Open firewall ports for Prometheus exporters + networking.firewall = { + allowedTCPPorts = [ + 9100 # node exporter + 9256 # process exporter + ]; + }; +} diff --git a/nixos/tsuba/services/default.nix b/nixos/tsuba/services/default.nix index eb5cc7d1..795a267b 100644 --- a/nixos/tsuba/services/default.nix +++ b/nixos/tsuba/services/default.nix @@ -1,4 +1,5 @@ -{...}: { +{ ... }: +{ imports = [ ./tailscale.nix ./samba.nix @@ -9,6 +10,7 @@ ./homeassistant.nix ./flaresolverr.nix ./caddy.nix + ./monitoring.nix # ./grafana.nix # ./dnscrypt.nix # ./resolved.nix diff --git a/nixos/tsuba/services/monitoring.nix b/nixos/tsuba/services/monitoring.nix new file mode 100644 index 00000000..1be5aa31 --- /dev/null +++ b/nixos/tsuba/services/monitoring.nix @@ -0,0 +1,42 @@ +{ ... }: +{ + services = { + prometheus = { + exporters = { + node = { + enable = true; + enabledCollectors = [ + "systemd" + "textfile" + "filesystem" + "loadavg" + "meminfo" + "netdev" + "stat" + "time" + "uname" + "vmstat" + ]; + port = 9100; + }; + process = { + enable = true; + settings.process_names = [ + { + name = "{{.Comm}}"; + cmdline = [ ".*" ]; + } + ]; + }; + }; + }; + }; + + # Open firewall ports for Prometheus exporters + networking.firewall = { + allowedTCPPorts = [ + 9100 # node exporter + 9256 # process exporter + ]; + }; +}