Merge pull request #121599 from Ma27/knot-exporter-patch

prometheus-knot-exporter: add patch to fix stats
This commit is contained in:
WilliButz 2021-05-04 01:02:28 +02:00 committed by GitHub
commit a2adfae036
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View file

@ -334,13 +334,48 @@ let
services.knot = {
enable = true;
extraArgs = [ "-v" ];
extraConfig = ''
server:
listen: 127.0.0.1@53
template:
- id: default
global-module: mod-stats
dnssec-signing: off
zonefile-sync: -1
journal-db: /var/lib/knot/journal
kasp-db: /var/lib/knot/kasp
timer-db: /var/lib/knot/timer
zonefile-load: difference
storage: ${pkgs.buildEnv {
name = "foo";
paths = [
(pkgs.writeTextDir "test.zone" ''
@ SOA ns.example.com. noc.example.com. 2019031301 86400 7200 3600000 172800
@ NS ns1
@ NS ns2
ns1 A 192.168.0.1
'')
];
}}
mod-stats:
- id: custom
edns-presence: on
query-type: on
zone:
- domain: test
file: test.zone
module: mod-stats/custom
'';
};
};
exporterTest = ''
wait_for_unit("knot.service")
wait_for_unit("prometheus-knot-exporter.service")
wait_for_open_port(9433)
succeed("curl -sSf 'localhost:9433' | grep -q 'knot_server_zone_count 0.0'")
succeed("curl -sSf 'localhost:9433' | grep -q 'knot_server_zone_count 1.0'")
'';
};

View file

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, lib, python3, nixosTests }:
{ stdenv, fetchFromGitHub, lib, python3, nixosTests, fetchpatch }:
stdenv.mkDerivation rec {
pname = "knot-exporter";
@ -11,6 +11,15 @@ stdenv.mkDerivation rec {
sha256 = "sha256-4au4lpaq3jcqC2JXdCcf8h+YN8Nmm4eE0kZwA+1rWlc=";
};
patches = [
# Fixes a crash with all metrics enabled. See
# https://github.com/ghedo/knot_exporter/pull/6 for further context.
(fetchpatch {
url = "https://github.com/ghedo/knot_exporter/commit/2317476e080369450ae51a707ccd30d4b89d680f.patch";
sha256 = "sha256-yEPu8EE1V/draNx9DeMrPj+bMfJRxauweo33dITl4AA=";
})
];
dontBuild = true;
nativeBuildInputs = [ python3.pkgs.wrapPython ];