From 1eeccb54a2ca0a2451781c0d528a410dbffae3c2 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 19 Jul 2019 16:04:45 +0200 Subject: wolf.r: graphite.shack redirect to graphite:8080 --- krebs/1systems/wolf/config.nix | 8 ++-- krebs/2configs/graphite.nix | 93 ------------------------------------ krebs/2configs/shack/graphite.nix | 99 +++++++++++++++++++++++++++++++++++++++ krebs/2configs/shack/influx.nix | 18 +++++++ 4 files changed, 121 insertions(+), 97 deletions(-) delete mode 100644 krebs/2configs/graphite.nix create mode 100644 krebs/2configs/shack/graphite.nix create mode 100644 krebs/2configs/shack/influx.nix diff --git a/krebs/1systems/wolf/config.nix b/krebs/1systems/wolf/config.nix index 3cb358ca..3c3cf61f 100644 --- a/krebs/1systems/wolf/config.nix +++ b/krebs/1systems/wolf/config.nix @@ -42,19 +42,19 @@ in # connect to git.shackspace.de as group runner for rz - # Statistics collection and visualization - + # Statistics collection and visualization + ## Collect data from mqtt.shack and store in graphite database ## Collect radioactive data and put into graphite ## mqtt.shack + ## influx.shack + ## Collect local statistics via collectd and send to collectd - { services.influxdb.enable = true; } - diff --git a/krebs/2configs/graphite.nix b/krebs/2configs/graphite.nix deleted file mode 100644 index 64222e43..00000000 --- a/krebs/2configs/graphite.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ config, lib, pkgs, ... }: - -# graphite-web on port 8080 -# carbon cache on port 2003 (tcp/udp) - -# TODO: krebs.graphite.minimal.enable -# TODO: configure firewall -with import ; -{ - imports = [ ]; - - services.graphite = { - api = { - enable = true; - listenAddress = "0.0.0.0"; - }; - carbon = { - enableCache = true; - # save disk usage by restricting to 1 bulk update per second - config = '' - [cache] - MAX_CACHE_SIZE = inf - MAX_UPDATES_PER_SECOND = 1 - MAX_CREATES_PER_MINUTE = 50 - MAX_UPDATES_PER_SECOND_ONSHUTDOWN = 9001 - - LOG_CACHE_HITS = False - LOG_CACHE_QUEUE_SORTS = False - LOG_UPDATES = False - LOG_LISTENER_CONNECTIONS = False - LOG_CREATES = True - ''; - storageAggregation = '' - ''; - storageSchemas = '' - [carbon] - pattern = ^carbon\. - retentions = 60:90d - - - [radiation_sensor] - pattern = ^sensors\.radiation\. - retentions = 1m:30d,5m:180d,10m:3y - - [motion_sensors] - pattern = ^sensors\.motion\. - retentions = 1s:1h,60s:30d,300s:1y - - [motion_sensors] - pattern = ^retiolum\. - retentions = 10s:1h,30s:30d,300s:1y - - [homeassistant] - pattern = ^homeassistant\. - retentions = 10s:24h,30s:30d,300s:1y,3600s:5y - - [ara] - pattern = ^ara\. - retentions = 60s:30d,300s:1y - - [openweathermap] - pattern = ^weather\.openweathermap - retentions = 30m:30d,1h:5y - - [stadtklima] - pattern = ^weather\.stadtklima-stuttgart - retentions = 15m:30d,30m:5y - - [sensebox] - pattern = ^weather\.sensebox - retentions = 1m:90d,30m:5y - - [elchos] - pattern = ^elchos\. - retentions = 10s:14d,1m:90d,10m:5y - - [icinga_default] - pattern = ^icinga - retentions = 10s:14d,5m:90d,10m:5y - - [icinga_internals] - pattern = ^icinga.*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type) - retentions = 5m:7d - - [default] - pattern = .* - retentions = 60s:30d,300s:1y - ''; - }; - }; - systemd.services.carbonCache.serviceConfig.Restart="always"; - systemd.services.graphiteApi.serviceConfig.Restart="always"; -} diff --git a/krebs/2configs/shack/graphite.nix b/krebs/2configs/shack/graphite.nix new file mode 100644 index 00000000..1c8ec6a8 --- /dev/null +++ b/krebs/2configs/shack/graphite.nix @@ -0,0 +1,99 @@ +{ config, lib, pkgs, ... }: +# hostname: graphite.shack + + +# graphite-web on port 8080 +# carbon cache on port 2003 (tcp/udp) +let + port = 8080; +in { + networking.firewall.allowedTCPPorts = [ 2003 port ]; + networking.firewall.allowedUDPPorts = [ 2003 ]; + services.nginx.virtualHosts."graphite.shack" = { + locations."/" = { + proxyPass = "http://localhost:${toString port}/"; + }; + }; + services.graphite = { + api = { + inherit port; + enable = true; + listenAddress = "0.0.0.0"; + }; + carbon = { + enableCache = true; + # save disk usage by restricting to 1 bulk update per second + config = '' + [cache] + MAX_CACHE_SIZE = inf + MAX_UPDATES_PER_SECOND = 1 + MAX_CREATES_PER_MINUTE = 50 + MAX_UPDATES_PER_SECOND_ONSHUTDOWN = 9001 + + LOG_CACHE_HITS = False + LOG_CACHE_QUEUE_SORTS = False + LOG_UPDATES = False + LOG_LISTENER_CONNECTIONS = False + LOG_CREATES = True + ''; + storageAggregation = '' + ''; + storageSchemas = '' + [carbon] + pattern = ^carbon\. + retentions = 60:90d + + + [radiation_sensor] + pattern = ^sensors\.radiation\. + retentions = 1m:30d,5m:180d,10m:3y + + [motion_sensors] + pattern = ^sensors\.motion\. + retentions = 1s:1h,60s:30d,300s:1y + + [motion_sensors] + pattern = ^retiolum\. + retentions = 10s:1h,30s:30d,300s:1y + + [homeassistant] + pattern = ^homeassistant\. + retentions = 10s:24h,30s:30d,300s:1y,3600s:5y + + [ara] + pattern = ^ara\. + retentions = 60s:30d,300s:1y + + [openweathermap] + pattern = ^weather\.openweathermap + retentions = 30m:30d,1h:5y + + [stadtklima] + pattern = ^weather\.stadtklima-stuttgart + retentions = 15m:30d,30m:5y + + [sensebox] + pattern = ^weather\.sensebox + retentions = 1m:90d,30m:5y + + [elchos] + pattern = ^elchos\. + retentions = 10s:14d,1m:90d,10m:5y + + [icinga_default] + pattern = ^icinga + retentions = 10s:14d,5m:90d,10m:5y + + [icinga_internals] + pattern = ^icinga.*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type) + retentions = 5m:7d + + [default] + pattern = .* + retentions = 60s:30d,300s:1y + ''; + }; + }; + systemd.services.carbonCache.serviceConfig.Restart="always"; + systemd.services.graphiteApi.serviceConfig.Restart="always"; +} diff --git a/krebs/2configs/shack/influx.nix b/krebs/2configs/shack/influx.nix new file mode 100644 index 00000000..599416c9 --- /dev/null +++ b/krebs/2configs/shack/influx.nix @@ -0,0 +1,18 @@ +let + port = 8086; +in +{ + networking.firewall.allowedTCPPorts = [ port ]; # for legacy applications + services.nginx.virtualHosts."influx.shack" = { + locations."/" = { + proxyPass = "http://localhost:${toString port}/"; + }; + }; + services.influxdb = { + enable = true; + extraConfig = { + bind-address = ":${toString port}"; + http.log-enabled = false; + }; + }; +} -- cgit v1.2.3