From dad24416b1ca61a5551db0de863b047765ac0454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hendrik=20S=C3=B6bbing?= Date: Mon, 18 Dec 2023 08:24:24 +0100 Subject: [PATCH] Add settings for InfluxDB --- examples/influxdb/.test.sh | 3 +- examples/influxdb/devenv.lock | 150 ++++++++++++++++++++++++++++++ examples/influxdb/devenv.nix | 67 ++++++++++++- src/modules/services/influxdb.nix | 8 +- 4 files changed, 225 insertions(+), 3 deletions(-) create mode 100644 examples/influxdb/devenv.lock diff --git a/examples/influxdb/.test.sh b/examples/influxdb/.test.sh index 2b345dba0..9b79b708f 100755 --- a/examples/influxdb/.test.sh +++ b/examples/influxdb/.test.sh @@ -11,7 +11,8 @@ function stop() { trap stop EXIT -timeout 10 bash -c 'until echo > /dev/tcp/localhost/8086; do sleep 0.5; done' +# We test for the none-default port, configured in the nix file +timeout 10 bash -c 'until echo > /dev/tcp/localhost/8087; do sleep 0.5; done' influx --execute "CREATE DATABASE devenv" DATABASES=$(influx --execute "SHOW DATABASES" | grep devenv) diff --git a/examples/influxdb/devenv.lock b/examples/influxdb/devenv.lock new file mode 100644 index 000000000..8d6215a6c --- /dev/null +++ b/examples/influxdb/devenv.lock @@ -0,0 +1,150 @@ +{ + "nodes": { + "devenv": { + "locked": { + "path": "../../src/modules", + "type": "path" + }, + "original": { + "path": "../../src/modules", + "type": "path" + }, + "parent": [] + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1702539185, + "narHash": "sha256-KnIRG5NMdLIpEkZTnN5zovNYc0hhXjAgv6pfd5Z4c7U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "aa9d4729cbc99dabacb50e3994dcefb3ea0f7447", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1702456155, + "narHash": "sha256-I2XhXGAecdGlqi6hPWYT83AQtMgL+aa3ulA85RAEgOk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "007a45d064c1c32d04e1b8a0de5ef00984c419bc", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/examples/influxdb/devenv.nix b/examples/influxdb/devenv.nix index 7d6234f21..9b30de689 100644 --- a/examples/influxdb/devenv.nix +++ b/examples/influxdb/devenv.nix @@ -1,9 +1,74 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: +let + cfg = config.services.influxdb; +in { packages = [ pkgs.influxdb ]; services.influxdb.enable = true; + services.influxdb.settings = '' + [meta] + dir = "/tmp/influxdb/meta" + + [data] + dir = "/tmp/influxdb/data" + wal-dir = "/tmp/influxdb/wal" + query-log-enabled = true + cache-max-memory-size = 1048576000 + cache-snapshot-memory-size = 26214400 + cache-snapshot-write-cold-duration = "10m" + compact-full-write-cold-duration = "4h" + + [coordinator] + write-timeout = "10s" + max-concurrent-queries = 0 + query-timeout = "0s" + log-queries-after = "0s" + max-select-point = 0 + max-select-series = 0 + max-select-buckets = 0 + + [retention] + enabled = true + check-interval = "30m" + + [shard-precreation] + enabled = true + check-interval = "10m" + advance-period = "30m" + + [monitor] + store-enabled = true + store-database = "_internal" + store-interval = "10s" + + [http] + enabled = true + bind-address = ":8087" + auth-enabled = false + log-enabled = true + write-tracing = false + pprof-enabled = true + https-enabled = false + + [logging] + format = "auto" + level = "info" + suppress-logo = false + + [[graphite]] + enabled = false + + [[collectd]] + enabled = false + + [[opentsdb]] + enabled = false + + [[udp]] + enabled = false + ''; } diff --git a/src/modules/services/influxdb.nix b/src/modules/services/influxdb.nix index 5ce946d95..9fe1e09be 100644 --- a/src/modules/services/influxdb.nix +++ b/src/modules/services/influxdb.nix @@ -14,9 +14,15 @@ in default = pkgs.influxdb; defaultText = lib.literalExpression "pkgs.influxdb"; }; + + settings = lib.mkOption { + type = types.lines; + default = ""; + description = "Configuration for InfluxDB-server"; + }; }; config = lib.mkIf cfg.enable { - processes.influxdb-server.exec = "${cfg.package}/bin/influxd"; + processes.influxdb-server.exec = "${cfg.package}/bin/influxd -config ${pkgs.writeText "influxdb.conf" cfg.settings}"; }; }