mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
feat(access): monitoring
This commit is contained in:
parent
511a02931a
commit
0397043f88
13 changed files with 323 additions and 94 deletions
50
nixos/access/grafana.nix
Normal file
50
nixos/access/grafana.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (config.services) grafana;
|
||||
name.shortServer = mkDefault "mon";
|
||||
upstreamName = "grafana'access";
|
||||
in {
|
||||
config.services.nginx = {
|
||||
upstreams'.${upstreamName}.servers = {
|
||||
local = {
|
||||
enable = mkDefault grafana.enable;
|
||||
addr = mkDefault "localhost";
|
||||
port = mkIf grafana.enable (mkDefault grafana.settings.server.http_port);
|
||||
};
|
||||
service = {upstream, ...}: {
|
||||
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
||||
accessService = {
|
||||
name = "grafana";
|
||||
};
|
||||
};
|
||||
};
|
||||
virtualHosts = let
|
||||
copyFromVhost = mkDefault "grafana";
|
||||
vouch.enable = mkDefault true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxy.enable = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
grafana = {
|
||||
inherit name locations vouch;
|
||||
proxy.upstream = mkDefault upstreamName;
|
||||
};
|
||||
grafana'local = {
|
||||
inherit name locations;
|
||||
ssl.cert = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
proxy = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
local.enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
51
nixos/access/loki.nix
Normal file
51
nixos/access/loki.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (config.services) loki;
|
||||
name.shortServer = mkDefault "logs";
|
||||
upstreamName = "loki'access";
|
||||
in {
|
||||
config.services.nginx = {
|
||||
# TODO: gRPC port?
|
||||
upstreams'.${upstreamName}.servers = {
|
||||
local = {
|
||||
enable = mkDefault loki.enable;
|
||||
addr = mkDefault "localhost";
|
||||
port = mkIf loki.enable (mkDefault loki.configuration.server.http_listen_port);
|
||||
};
|
||||
service = {upstream, ...}: {
|
||||
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
||||
accessService = {
|
||||
name = "loki";
|
||||
};
|
||||
};
|
||||
};
|
||||
virtualHosts = let
|
||||
copyFromVhost = mkDefault "loki";
|
||||
vouch.enable = mkDefault true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxy.enable = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
loki = {
|
||||
inherit name locations vouch;
|
||||
proxy.upstream = mkDefault upstreamName;
|
||||
};
|
||||
loki'local = {
|
||||
inherit name locations vouch;
|
||||
ssl.cert = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
proxy = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
local.enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
50
nixos/access/prometheus.nix
Normal file
50
nixos/access/prometheus.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (config.services) prometheus;
|
||||
name.shortServer = mkDefault "prometheus";
|
||||
upstreamName = "prometheus'access";
|
||||
in {
|
||||
config.services.nginx = {
|
||||
upstreams'.${upstreamName}.servers = {
|
||||
local = {
|
||||
enable = mkDefault prometheus.enable;
|
||||
addr = mkDefault "localhost";
|
||||
port = mkIf prometheus.enable (mkDefault prometheus.port);
|
||||
};
|
||||
service = {upstream, ...}: {
|
||||
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
||||
accessService = {
|
||||
name = "prometheus";
|
||||
};
|
||||
};
|
||||
};
|
||||
virtualHosts = let
|
||||
copyFromVhost = mkDefault "prometheus";
|
||||
vouch.enable = mkDefault true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxy.enable = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
prometheus = {
|
||||
inherit name locations vouch;
|
||||
proxy.upstream = mkDefault upstreamName;
|
||||
};
|
||||
prometheus'local = {
|
||||
inherit name locations;
|
||||
ssl.cert = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
proxy = {
|
||||
inherit copyFromVhost;
|
||||
};
|
||||
local.enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue