VictoriaMetrics: init at v1.32.5, add module, tests (#78038)

VictoriaMetrics: init at v1.32.5, add module, tests
This commit is contained in:
Silvan Mosberger 2020-01-30 14:02:42 +01:00 committed by GitHub
commit 32718c9992
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 0 deletions

View file

@ -281,6 +281,7 @@
./services/databases/riak.nix
./services/databases/riak-cs.nix
./services/databases/stanchion.nix
./services/databases/victoriametrics.nix
./services/databases/virtuoso.nix
./services/desktops/accountsservice.nix
./services/desktops/bamf.nix

View file

@ -0,0 +1,70 @@
{ config, pkgs, lib, ... }:
let cfg = config.services.victoriametrics; in
{
options.services.victoriametrics = with lib; {
enable = mkEnableOption "victoriametrics";
package = mkOption {
type = types.package;
default = pkgs.victoriametrics;
defaultText = "pkgs.victoriametrics";
description = ''
The VictoriaMetrics distribution to use.
'';
};
listenAddress = mkOption {
default = ":8428";
type = types.str;
description = ''
The listen address for the http interface.
'';
};
retentionPeriod = mkOption {
type = types.int;
default = 1;
description = ''
Retention period in months.
'';
};
extraOptions = mkOption {
type = types.listOf types.str;
default = [];
description = ''
Extra options to pass to VictoriaMetrics. See the README: <link
xlink:href="https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/README.md" />
or <command>victoriametrics -help</command> for more
information.
'';
};
};
config = lib.mkIf cfg.enable {
systemd.services.victoriametrics = {
description = "VictoriaMetrics time series database";
after = [ "network.target" ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 1;
StartLimitBurst = 5;
StateDirectory = "victoriametrics";
DynamicUser = true;
ExecStart = ''
${cfg.package}/bin/victoria-metrics \
-storageDataPath=/var/lib/victoriametrics \
-httpListenAddr ${cfg.listenAddress}
-retentionPeriod ${toString cfg.retentionPeriod}
${lib.escapeShellArgs cfg.extraOptions}
'';
};
wantedBy = [ "multi-user.target" ];
postStart =
let
bindAddr = (lib.optionalString (lib.hasPrefix ":" cfg.listenAddress) "127.0.0.1") + cfg.listenAddress;
in
lib.mkBefore ''
until ${lib.getBin pkgs.curl}/bin/curl -s -o /dev/null http://${bindAddr}/ping; do
sleep 1;
done
'';
};
};
}

View file

@ -293,6 +293,7 @@ in
upnp = handleTest ./upnp.nix {};
uwsgi = handleTest ./uwsgi.nix {};
vault = handleTest ./vault.nix {};
victoriametrics = handleTest ./victoriametrics.nix {};
virtualbox = handleTestOn ["x86_64-linux"] ./virtualbox.nix {};
wireguard = handleTest ./wireguard {};
wireguard-generated = handleTest ./wireguard/generated.nix {};

View file

@ -0,0 +1,31 @@
# This test runs influxdb and checks if influxdb is up and running
import ./make-test-python.nix ({ pkgs, ...} : {
name = "victoriametrics";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ yorickvp ];
};
nodes = {
one = { ... }: {
services.victoriametrics.enable = true;
};
};
testScript = ''
start_all()
one.wait_for_unit("victoriametrics.service")
# write some points and run simple query
out = one.succeed(
"curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST 'http://localhost:8428/write'"
)
cmd = """curl -s -G 'http://localhost:8428/api/v1/export' -d 'match={__name__!=""}'"""
# data takes a while to appear
one.wait_until_succeeds(f"[[ $({cmd} | wc -l) -ne 0 ]]")
out = one.succeed(cmd)
assert '"values":[123]' in out
assert '"values":[1.23]' in out
'';
})

View file

@ -0,0 +1,21 @@
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "VictoriaMetrics";
version = "1.32.5";
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "v${version}";
sha256 = "1i3l8bkii3x8wnq9a8yn48cchni5h0gy3rrpvg0jgm4kmm5dlq4y";
};
modSha256 = "0696p1hv5z3dvawizvw0yi4xzl41bsmszkdqayzb37nm5cfk8riq";
meta = with lib; {
homepage = "https://victoriametrics.com/";
description = "fast, cost-effective and scalable time series database, long-term remote storage for Prometheus";
license = licenses.asl20;
maintainers = [ maintainers.yorickvp ];
};
}

View file

@ -15886,6 +15886,8 @@ in
unifiStable;
unifi = unifiStable;
victoriametrics = callPackage ../servers/nosql/victoriametrics { };
virtlyst = libsForQt5.callPackage ../servers/web-apps/virtlyst { };
virtuoso6 = callPackage ../servers/sql/virtuoso/6.x.nix {