Added Prometheus Exporter to std config; Added Grafana;
This commit is contained in:
12
flake.nix
12
flake.nix
@@ -120,19 +120,17 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
platformModules =
|
platformModules =
|
||||||
let
|
|
||||||
nixosBase = [
|
|
||||||
{ nixpkgs.hostPlatform = system; }
|
|
||||||
./nixos
|
|
||||||
];
|
|
||||||
in
|
|
||||||
if isDarwin then
|
if isDarwin then
|
||||||
[
|
[
|
||||||
./darwin
|
./darwin
|
||||||
inputs.nix-homebrew.darwinModules.nix-homebrew
|
inputs.nix-homebrew.darwinModules.nix-homebrew
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
nixosBase ++ (if isServer then [ ./nixos/server ] else [ ]);
|
[
|
||||||
|
{ nixpkgs.hostPlatform = system; }
|
||||||
|
./nixos
|
||||||
|
];
|
||||||
|
|
||||||
in
|
in
|
||||||
systemFunc {
|
systemFunc {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
imports = [ ./hardware-configuration.nix ];
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
../../nixos/roles/monitoring.nix
|
||||||
|
];
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
useNetworkd = true;
|
useNetworkd = true;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
lib,
|
lib,
|
||||||
primaryUser,
|
primaryUser,
|
||||||
isServer,
|
isServer,
|
||||||
|
isDarwin,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -82,10 +83,17 @@
|
|||||||
apparmor.enable = false;
|
apparmor.enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.gnome = lib.mkIf (!isServer) {
|
services = {
|
||||||
|
prometheus.exporters.node = lib.mkIf (!isDarwin) {
|
||||||
|
enable = true;
|
||||||
|
port = 9002;
|
||||||
|
};
|
||||||
|
|
||||||
|
gnome = lib.mkIf (!isServer) {
|
||||||
tinysparql.enable = true;
|
tinysparql.enable = true;
|
||||||
localsearch.enable = true;
|
localsearch.enable = true;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
users.users.${primaryUser} = {
|
users.users.${primaryUser} = {
|
||||||
home = "/home/${primaryUser}";
|
home = "/home/${primaryUser}";
|
||||||
|
|||||||
41
nixos/roles/monitoring.nix
Normal file
41
nixos/roles/monitoring.nix
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
grafana = {
|
||||||
|
enable = true;
|
||||||
|
domain = "grafana.cyperpunk.de";
|
||||||
|
port = 2342;
|
||||||
|
addr = "127.0.0.1";
|
||||||
|
};
|
||||||
|
|
||||||
|
# nginx reverse proxy
|
||||||
|
nginx.virtualHosts.${config.services.grafana.domain} = {
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}";
|
||||||
|
proxyWebsockets = true;
|
||||||
|
extraConfig = ''
|
||||||
|
proxy_set_header Host ${config.services.grafana.domain};
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
prometheus = {
|
||||||
|
enable = true;
|
||||||
|
port = 9001;
|
||||||
|
scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = config.networking.hostName;
|
||||||
|
static_configs = [
|
||||||
|
{
|
||||||
|
targets = [
|
||||||
|
"${config.networking.primaryIPAddress}:${toString config.services.prometheus.exporters.node.port}"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
services.nginx = {
|
|
||||||
enable = true;
|
|
||||||
virtualHosts.localhost = {
|
|
||||||
locations."/" = {
|
|
||||||
return = "200 '<html><body>It works</body></html>'";
|
|
||||||
extraConfig = ''
|
|
||||||
default_type text/html;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user