Skip to content

Commit

Permalink
Merge pull request #903 from soebbing/influxdb
Browse files Browse the repository at this point in the history
Add influxdb module
  • Loading branch information
domenkozar authored Dec 20, 2023
2 parents e681a99 + d4b9af6 commit 85f6e9c
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/influxdb/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -ex

devenv up &
DEVENV_PID=$!
export DEVENV_PID

function stop() {
pkill -P "$DEVENV_PID"
}

trap stop EXIT

# We test for the none-default port, configured in the nix file
timeout 60 bash -c 'until echo > /dev/tcp/localhost/8087; do sleep 0.5; done'

influx --port 8087 --execute "CREATE DATABASE devenv"
DATABASES=$(influx --port 8087 --execute "SHOW DATABASES" | grep devenv)

if [[ "$DATABASES" != "devenv" ]]; then
echo "The influxdb database was not created"
exit 1
fi
74 changes: 74 additions & 0 deletions examples/influxdb/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{ pkgs, config, ... }:

let
cfg = config.services.influxdb;
in
{
packages = [
pkgs.influxdb
];

services.influxdb.enable = true;
services.influxdb.config = ''
[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
'';
}
3 changes: 3 additions & 0 deletions examples/influxdb/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
28 changes: 28 additions & 0 deletions src/modules/services/influxdb.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ pkgs, lib, config, ... }:

let
cfg = config.services.influxdb;
types = lib.types;
in
{
options.services.influxdb = {
enable = lib.mkEnableOption "influxdb";

package = lib.mkOption {
type = types.package;
description = "An open-source distributed time series database";
default = pkgs.influxdb;
defaultText = lib.literalExpression "pkgs.influxdb";
};

config = lib.mkOption {
type = types.lines;
default = "";
description = "Configuration for InfluxDB-server";
};
};

config = lib.mkIf cfg.enable {
processes.influxdb-server.exec = "${cfg.package}/bin/influxd -config ${pkgs.writeText "influxdb.conf" cfg.config}";
};
}

0 comments on commit 85f6e9c

Please sign in to comment.