Heracles FTW

This commit is contained in:
Jeremy Wall 2024-02-23 11:58:30 -05:00
parent c9d6f0f5e8
commit d75180b59b
4 changed files with 296 additions and 46 deletions

View File

@ -42,6 +42,50 @@
services.node-exporter.enable = true;
services.prometheus.enable = true;
services.heracles.enable = true;
services.heracles.settings = [
{
title = "Metrics";
span = {
end = "now";
duration = "1d";
step_duration = "5min";
};
graphs = [
{
title = "CPU and Mem Used";
query_type = "Range";
plots = [
{ # CPU plot
source = "http://${config.services.prometheus.listen}";
query = ''
sum by (job,instance, mode)(irate(node_cpu_seconds_total[5m]))
/ ignoring(mode) group_left
sum by (job,instance)(irate(node_cpu_seconds_total[5m]))
'';
meta = {
name_format = "`\${labels.instance} - \${labels.mode}`";
d3_tick_format = "~%";
};
}
{ # Memory Usage
source = "http://${config.services.prometheus.listen}";
query = ''
(node_memory_wired_bytes
+ node_memory_compressed_bytes
+ node_memory_active_bytes)
/ node_memory_total_bytes
'';
meta = {
name_format = "`\${labels.instance} - Memory`";
d3_tick_format = "~%";
};
}
];
}
];
}
];
# TODO launchd.user.agents.prometheus;
# Use a custom configuration.nix location.

View File

@ -115,6 +115,22 @@
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1648199409,
@ -130,7 +146,7 @@
"type": "github"
}
},
"flake-compat_3": {
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1673956053,
@ -165,6 +181,42 @@
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1687709756,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
@ -179,7 +231,7 @@
"type": "github"
}
},
"flake-utils_3": {
"flake-utils_5": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
@ -194,9 +246,9 @@
"type": "github"
}
},
"flake-utils_4": {
"flake-utils_6": {
"inputs": {
"systems": "systems_2"
"systems": "systems_4"
},
"locked": {
"lastModified": 1681202837,
@ -212,9 +264,9 @@
"type": "github"
}
},
"flake-utils_5": {
"flake-utils_7": {
"inputs": {
"systems": "systems_3"
"systems": "systems_5"
},
"locked": {
"lastModified": 1681202837,
@ -268,6 +320,28 @@
"type": "github"
}
},
"heracles-flake": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"naersk": "naersk_2",
"nixpkgs": "nixpkgs_4",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1708705477,
"narHash": "sha256-8E0RSUf/UJSAANOhPRj/EE0de35m/l11SU4AJggNtxA=",
"owner": "zaphar",
"repo": "Heracles",
"rev": "b1b65bbbecd20a7921711dba2d6dc34a4687d139",
"type": "github"
},
"original": {
"owner": "zaphar",
"repo": "Heracles",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -325,7 +399,25 @@
},
"naersk_2": {
"inputs": {
"nixpkgs": "nixpkgs_6"
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"owner": "nix-community",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"naersk_3": {
"inputs": {
"nixpkgs": "nixpkgs_8"
},
"locked": {
"lastModified": 1650101877,
@ -343,9 +435,9 @@
},
"nil-flake": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3",
"rust-overlay": "rust-overlay"
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_5",
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1694177726,
@ -408,6 +500,34 @@
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1708151420,
"narHash": "sha256-MGT/4aGCWQPQiu6COqJdCj9kSpLPiShgbwpbC38YXC8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6e2f00c83911461438301db0dba5281197fe4b3a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1708151420,
"narHash": "sha256-MGT/4aGCWQPQiu6COqJdCj9kSpLPiShgbwpbC38YXC8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6e2f00c83911461438301db0dba5281197fe4b3a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1690441914,
"narHash": "sha256-Ac+kJQ5z9MDAMyzSc0i0zJDx2i3qi9NjlW5Lz285G/I=",
@ -423,7 +543,7 @@
"type": "github"
}
},
"nixpkgs_4": {
"nixpkgs_6": {
"locked": {
"lastModified": 1701282334,
"narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=",
@ -439,7 +559,7 @@
"type": "github"
}
},
"nixpkgs_5": {
"nixpkgs_7": {
"locked": {
"lastModified": 1689850295,
"narHash": "sha256-fUYf6WdQlhd2H+3aR8jST5dhFH1d0eE22aes8fNIfyk=",
@ -455,7 +575,7 @@
"type": "github"
}
},
"nixpkgs_6": {
"nixpkgs_8": {
"locked": {
"lastModified": 1650109093,
"narHash": "sha256-tqlnKrAdJktRLXTou9le0oTqrYBAFpGscV5RADdpArU=",
@ -469,7 +589,7 @@
"type": "indirect"
}
},
"nixpkgs_7": {
"nixpkgs_9": {
"locked": {
"lastModified": 1682109806,
"narHash": "sha256-d9g7RKNShMLboTWwukM+RObDWWpHKaqTYXB48clBWXI=",
@ -487,7 +607,7 @@
},
"nurl-flake": {
"inputs": {
"nixpkgs": "nixpkgs_5"
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1701273941,
@ -510,8 +630,9 @@
"darwin": "darwin_2",
"durnitisp-flake": "durnitisp-flake",
"harpoon-src": "harpoon-src",
"heracles-flake": "heracles-flake",
"nil-flake": "nil-flake",
"nixpkgs": "nixpkgs_4",
"nixpkgs": "nixpkgs_6",
"nixpkgs-darwin": "nixpkgs-darwin",
"nurl-flake": "nurl-flake",
"roslyn-lsp": "roslyn-lsp",
@ -541,9 +662,9 @@
},
"runwhen-flake": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"naersk": "naersk_2"
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_5",
"naersk": "naersk_3"
},
"locked": {
"lastModified": 1695686584,
@ -560,6 +681,50 @@
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [
"heracles-flake",
"nixpkgs"
]
},
"locked": {
"lastModified": 1707444620,
"narHash": "sha256-P8kRkiJLFttN+hbAOlm11wPxUrQZqKle+QtVCqFiGXY=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "78503e9199010a4df714f29a4f9c00eb2ccae071",
"type": "github"
},
"original": {
"owner": "oxalica",
"ref": "stable",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay-flake": {
"inputs": {
"flake-utils": "flake-utils_6",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1694743934,
"narHash": "sha256-4pn0x+OiOFWefBpgyufFVaAeG+LwfVUI/HMCma8xdHU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "6a26dd6da9b4f28d9b4c397bd22b5df4bec8f78a",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"nil-flake",
@ -584,34 +749,13 @@
"type": "github"
}
},
"rust-overlay-flake": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1694743934,
"narHash": "sha256-4pn0x+OiOFWefBpgyufFVaAeG+LwfVUI/HMCma8xdHU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "6a26dd6da9b4f28d9b4c397bd22b5df4bec8f78a",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"sile-flake": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_5",
"flake-compat": "flake-compat_4",
"flake-utils": "flake-utils_7",
"gitignore": "gitignore",
"libtexpdf-src": "libtexpdf-src",
"nixpkgs": "nixpkgs_7"
"nixpkgs": "nixpkgs_9"
},
"locked": {
"lastModified": 1694595810,
@ -672,6 +816,36 @@
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_5": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treesitter-context": {
"flake": false,
"locked": {

View File

@ -38,11 +38,11 @@
url = "github:nvim-treesitter/nvim-treesitter-context/e6b743ccd4e780bc9cd85b707de67df72eea1a23";
flake = false;
};
# We need to pin to this version of treesitter because it breaks after this revision
roslyn-lsp = {
url = "github:zaphar/roslyn.nvim/non_nightly";
flake = false;
};
heracles-flake.url = "github:zaphar/Heracles";
};
outputs = {
@ -60,6 +60,7 @@
roslyn-lsp,
#lean4-flake,
unstable,
heracles-flake,
... # We don't use the self or nixpkgs args here so we just glob it.
}:
rec {
@ -217,6 +218,7 @@ EOF";
(final: prev: {
# This is needed because the ccache used by lean4Pkg is broken
ccache = prev.ccache.override { doCheck = false; };
heracles = heracles-flake.packages."${system}".default;
})
rust-overlay
];

View File

@ -10,7 +10,21 @@ with lib;
defaultText = "localhost:9100";
};
};
options.services.heracles = {
enable = mkEnableOption "Enable the heracles server";
listen = mkOption {
description = "[host]:port to listen on for the heracles server";
default = "localhost:9001";
defaultText = "localhost:9001";
};
settings = mkOption {
description = "Settings for the heracles dashboards";
default = [];
defaultText = "[]";
};
};
options.services.prometheus = {
enable = lib.mkEnableOption "Enable the prometheus server";
listen = mkOption {
@ -39,7 +53,7 @@ with lib;
defaultText = ''{
scrape_configs = [
{
job_name = "node_exporter";
job_name = "nodestats";
scrape_interval = "30s";
metrics_path = "/metrics";
static_configs = [
@ -76,7 +90,23 @@ with lib;
environment.etc."prometheus.yaml" = mkIf config.services.prometheus.enable {
text = (generators.toYAML {} config.services.prometheus.settings);
};
environment.etc."heracles.yaml" = mkIf config.services.heracles.enable {
text = (generators.toYAML {} config.services.heracles.settings);
};
launchd.user.agents.heracles = mkIf config.services.heracles.enable {
serviceConfig = {
ProgramArguments = [
"${pkgs.heracles}/bin/heracles"
"--listen=${config.services.heracles.listen}"
"--config=/etc/${config.environment.etc."heracles.yaml".target}"
];
KeepAlive = true;
RunAtLoad = true;
};
};
launchd.user.agents.prometheus = mkIf config.services.prometheus.enable {
serviceConfig = {
ProgramArguments = [