From bd90a14732f418f5d77ad2e925fe728940268f3e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 5 Feb 2017 22:34:16 +0100 Subject: m central-logging: init --- makefu/2configs/logging/central-logging-client.nix | 32 ++++++++++++++++++++++ makefu/2configs/logging/central-logging-server.nix | 23 ++++++++++++++++ makefu/2configs/logging/central-stats-server.nix | 6 ++-- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 makefu/2configs/logging/central-logging-client.nix create mode 100644 makefu/2configs/logging/central-logging-server.nix (limited to 'makefu/2configs/logging') diff --git a/makefu/2configs/logging/central-logging-client.nix b/makefu/2configs/logging/central-logging-client.nix new file mode 100644 index 000000000..04d2de0d0 --- /dev/null +++ b/makefu/2configs/logging/central-logging-client.nix @@ -0,0 +1,32 @@ +{pkgs, buil, config, ...}: +let + log-server = config.makefu.log-server; + log-port = 9200; +in { + services.journalbeat = { + enable = true; + # TODO: filter for certain journal fields, not all + extraConfig = '' + journalbeat: + name: logs-${config.krebs.build.host.name} + seek_position: cursor + cursor_seek_fallback: tail + write_cursor_state: true + cursor_flush_period: 5s + clean_field_names: true + convert_to_numbers: false + move_metadata_to_field: journal + default_type: journal + output.elasticsearch: + enabled: true + hosts: ["${log-server}:${builtins.toString log-port}"] + template.enabled: false + #output.console: + # enabled: true + logging.level: info + logging.to_syslog: true + logging.selectors: ["*"] + + ''; + }; +} diff --git a/makefu/2configs/logging/central-logging-server.nix b/makefu/2configs/logging/central-logging-server.nix new file mode 100644 index 000000000..e2cfe6948 --- /dev/null +++ b/makefu/2configs/logging/central-logging-server.nix @@ -0,0 +1,23 @@ +{pkgs, config, ...}: + +with import ; +let + es-port = 9200; + kibana-port = 5601; +in { + services.elasticsearch = { + enable = true; + listenAddress = "0.0.0.0"; + port = es-port; + }; + services.kibana = { + enable = true; + listenAddress = "0.0.0.0"; + port = kibana-port; + }; + + networking.firewall.extraCommands = '' + iptables -A INPUT -i retiolum -p tcp --dport ${toString es-port} -j ACCEPT + iptables -A INPUT -i retiolum -p tcp --dport ${toString es-port} -j ACCEPT + ''; +} diff --git a/makefu/2configs/logging/central-stats-server.nix b/makefu/2configs/logging/central-stats-server.nix index d4e73ab79..8151d4939 100644 --- a/makefu/2configs/logging/central-stats-server.nix +++ b/makefu/2configs/logging/central-stats-server.nix @@ -7,7 +7,7 @@ let grafana-port = 3000; # TODO nginx forward in { imports = [ - ../../lass/3modules/kapacitor.nix + ../../../lass/3modules/kapacitor.nix ]; services.grafana.enable = true; services.grafana.addr = "0.0.0.0"; @@ -45,11 +45,11 @@ in { alarms = { cpu_deadman = '' var data = batch - |query(''' + |query(${"'''"} SELECT mean("value") AS mean FROM "collectd_db"."default"."cpu_value" WHERE "type_instance" = 'idle' AND "type" = 'percent' fill(0) - ''') + ${"'''"}) .period(10m) .every(1m) .groupBy('host') -- cgit v1.2.3