2015-09-19 00:18:43 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.kibana;
|
|
|
|
|
|
|
|
cfgFile = pkgs.writeText "kibana.json" (builtins.toJSON (
|
|
|
|
(filterAttrsRecursive (n: v: v != null) ({
|
2016-02-13 15:01:45 +01:00
|
|
|
host = cfg.listenAddress;
|
|
|
|
port = cfg.port;
|
|
|
|
ssl_cert_file = cfg.cert;
|
|
|
|
ssl_key_file = cfg.key;
|
|
|
|
|
|
|
|
kibana_index = cfg.index;
|
|
|
|
default_app_id = cfg.defaultAppId;
|
|
|
|
|
|
|
|
elasticsearch_url = cfg.elasticsearch.url;
|
|
|
|
kibana_elasticsearch_username = cfg.elasticsearch.username;
|
|
|
|
kibana_elasticsearch_password = cfg.elasticsearch.password;
|
|
|
|
kibana_elasticsearch_cert = cfg.elasticsearch.cert;
|
|
|
|
kibana_elasticsearch_key = cfg.elasticsearch.key;
|
|
|
|
ca = cfg.elasticsearch.ca;
|
|
|
|
|
|
|
|
bundled_plugin_ids = [
|
|
|
|
"plugins/dashboard/index"
|
|
|
|
"plugins/discover/index"
|
|
|
|
"plugins/doc/index"
|
|
|
|
"plugins/kibana/index"
|
|
|
|
"plugins/markdown_vis/index"
|
|
|
|
"plugins/metric_vis/index"
|
|
|
|
"plugins/settings/index"
|
|
|
|
"plugins/table_vis/index"
|
|
|
|
"plugins/vis_types/index"
|
|
|
|
"plugins/visualize/index"
|
|
|
|
];
|
2015-09-19 00:18:43 +02:00
|
|
|
} // cfg.extraConf)
|
|
|
|
)));
|
|
|
|
in {
|
|
|
|
options.services.kibana = {
|
|
|
|
enable = mkEnableOption "enable kibana service";
|
|
|
|
|
2015-12-24 00:28:27 +01:00
|
|
|
listenAddress = mkOption {
|
2015-09-19 00:18:43 +02:00
|
|
|
description = "Kibana listening host";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
description = "Kibana listening port";
|
|
|
|
default = 5601;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
cert = mkOption {
|
|
|
|
description = "Kibana ssl certificate.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
key = mkOption {
|
|
|
|
description = "Kibana ssl key.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
index = mkOption {
|
|
|
|
description = "Elasticsearch index to use for saving kibana config.";
|
|
|
|
default = ".kibana";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultAppId = mkOption {
|
|
|
|
description = "Elasticsearch default application id.";
|
|
|
|
default = "discover";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
elasticsearch = {
|
|
|
|
url = mkOption {
|
|
|
|
description = "Elasticsearch url";
|
|
|
|
default = "http://localhost:9200";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
description = "Username for elasticsearch basic auth.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
description = "Password for elasticsearch basic auth.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
ca = mkOption {
|
|
|
|
description = "CA file to auth against elasticsearch.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
cert = mkOption {
|
|
|
|
description = "Certificate file to auth against elasticsearch.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
key = mkOption {
|
|
|
|
description = "Key file to auth against elasticsearch.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
description = "Kibana package to use";
|
|
|
|
default = pkgs.kibana;
|
2016-01-17 19:34:55 +01:00
|
|
|
defaultText = "pkgs.kibana";
|
2015-09-19 00:18:43 +02:00
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
description = "Kibana data directory";
|
|
|
|
default = "/var/lib/kibana";
|
|
|
|
type = types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConf = mkOption {
|
|
|
|
description = "Kibana extra configuration";
|
|
|
|
default = {};
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.enable) {
|
|
|
|
systemd.services.kibana = {
|
|
|
|
description = "Kibana Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" "elasticsearch.service" ];
|
2016-02-13 15:01:45 +01:00
|
|
|
environment = { BABEL_CACHE_PATH = "${cfg.dataDir}/.babelcache.json"; };
|
2015-09-19 00:18:43 +02:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${cfg.package}/bin/kibana --config ${cfgFile}";
|
|
|
|
User = "kibana";
|
|
|
|
WorkingDirectory = cfg.dataDir;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = "kibana";
|
|
|
|
uid = config.ids.uids.kibana;
|
|
|
|
description = "Kibana service user";
|
|
|
|
home = cfg.dataDir;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|