Refactored monitoring

This commit is contained in:
Craige McWhirter 2020-05-28 14:21:36 +10:00
parent bb5a755ed8
commit 6ea48c9b7c
Signed by: sercanto
GPG key ID: 7DBA9F5689EFB6AA
4 changed files with 92 additions and 69 deletions

View file

@ -8,7 +8,7 @@
[
../clusters/linode-encrypted.nix
../roles/cardano-node.nix
../roles/prometheus_cardano-node.nix
../roles/monitoring.nix
];
deployment.targetHost = "172.105.184.221";

47
roles/grafana.nix Normal file
View file

@ -0,0 +1,47 @@
# NixOps configuration for the hosts running Prometheus on a Cardano node
{ config, pkgs, lib, ... }:
{
imports = [
../secrets/cardano/grafana.nix
];
services = {
grafana = {
enable = true;
addr = "0.0.0.0";
domain = "monitoring.mcwhirter.io";
rootUrl = "https://monitoring.mcwhirter.io/grafana";
security = {
adminPasswordFile = "/run/keys/grafana-apass"; # Where to find the password
};
auth = {
anonymous = {
enable = true; # Allow anonymous access
};
};
provision = {
enable = true;
#dashboards = [
# {
# name = "Node System Dashboard";
# folder = "General";
# options.path = ../monitoring/NodeSystemDashboard.json;
# }
#];
datasources = [
{
type = "prometheus";
name = "prometheus";
url = "http://localhost:9090/prometheus";
}
];
};
};
};
users.groups.keys.members = [ "grafana" ]; # Required due to NixOps issue #1204
}

44
roles/monitoring.nix Normal file
View file

@ -0,0 +1,44 @@
# NixOps configuration for the monitoring host
{ config, pkgs, lib, ... }:
{
imports = [
./grafana.nix
./prometheus.nix
];
services = {
nginx = {
enable = true; # Enable Nginx
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."monitoring.mcwhirter.io" = { # Monitoring hostname
enableACME = true; # Use ACME certs
forceSSL = true; # Force SSL
locations = {
"/grafana/".proxyPass = "http://localhost:3000/"; # Proxy Grafana
"/prometheus/".extraConfig = ''
proxy_pass http://localhost:9090/prometheus/;
proxy_set_header Host $host;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
'';
};
};
};
};
security.acme = {
acceptTerms = true;
certs = {
"monitoring.mcwhirter.io".email = "craige@mcwhirter.io";
};
};
}

View file

@ -4,10 +4,6 @@
{
imports = [
../secrets/cardano/grafana.nix
];
services = {
prometheus = {
enable = true;
@ -225,70 +221,6 @@
];
};
grafana = {
enable = true;
addr = "0.0.0.0";
domain = "monitoring.mcwhirter.io";
rootUrl = "https://monitoring.mcwhirter.io/grafana";
security = {
adminPasswordFile = "/run/keys/grafana-apass"; # Where to find the password
};
auth = {
anonymous = {
enable = true; # Allow anonymous access
};
};
provision = {
enable = true;
#dashboards = [
# {
# name = "Node System Dashboard";
# folder = "General";
# options.path = ../monitoring/NodeSystemDashboard.json;
# }
#];
datasources = [
{
type = "prometheus";
name = "prometheus";
url = "http://localhost:9090/prometheus";
}
];
};
};
nginx = {
enable = true; # Enable Nginx
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."monitoring.mcwhirter.io" = { # Monitoring hostname
enableACME = true; # Use ACME certs
forceSSL = true; # Force SSL
locations = {
"/grafana/".proxyPass = "http://localhost:3000/"; # Proxy Grafana
"/prometheus/".extraConfig = ''
proxy_pass http://localhost:9090/prometheus/;
proxy_set_header Host $host;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
'';
#"/alertmanager/".proxyPass = "http://localhost:9093/"; # Proxy Alert Manager
};
};
};
};
users.groups.keys.members = [ "grafana" ]; # Required due to NixOps issue #1204
security.acme = {
acceptTerms = true;
certs = {
"monitoring.mcwhirter.io".email = "craige@mcwhirter.io";
};
};
}