Skip to content

Commit

Permalink
Add settings for InfluxDB
Browse files Browse the repository at this point in the history
  • Loading branch information
soebbing committed Dec 18, 2023
1 parent 0f96aa4 commit dad2441
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/influxdb/.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
150 changes: 150 additions & 0 deletions examples/influxdb/devenv.lock
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 66 additions & 1 deletion examples/influxdb/devenv.nix
Original file line number Diff line number Diff line change
@@ -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
'';
}
8 changes: 7 additions & 1 deletion src/modules/services/influxdb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
};
}

0 comments on commit dad2441

Please sign in to comment.