New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prometheus unbound exporter #120492
Prometheus unbound exporter #120492
Conversation
58772e4
to
089b537
Compare
089b537
to
4d511fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A VM test under nixos/tests/prometheus-exporters.nix
would be appreciated as well :)
nixos/modules/services/monitoring/prometheus/exporters/unbound.nix
Outdated
Show resolved
Hide resolved
nixos/modules/services/monitoring/prometheus/exporters/unbound.nix
Outdated
Show resolved
Hide resolved
nixos/modules/services/monitoring/prometheus/exporters/unbound.nix
Outdated
Show resolved
Hide resolved
4d511fa
to
40f6b0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @Ma27 already stated, a new exporter module should come with a VM test, validating at the very least the compatibility of module and package. To test the PR I wrote a small test case, feel free to apply the patch:
Basic VM Test
commit 2890a3dd15ae57865e7922f6dfd7f2e698cda3fd
Author: WilliButz <willibutz@posteo.de>
Date: Tue Apr 27 18:00:55 2021 +0200
nixos/tests/prometheus-exporters: add unbound test
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
index 62c0080dd51..1afb49c9cf8 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -1000,6 +1000,29 @@ let
'';
};
+ unbound = {
+ exporterConfig = {
+ enable = true;
+ fetchType = "uds";
+ socketPath = "/run/unbound/unbound.ctl";
+ };
+ metricProvider = {
+ services.unbound = {
+ enable = true;
+ localControlSocketPath = "/run/unbound/unbound.ctl";
+ };
+ systemd.services.prometheus-unbound-exporter.serviceConfig = {
+ SupplementaryGroups = [ "unbound" ];
+ };
+ };
+ exporterTest = ''
+ wait_for_unit("unbound.service")
+ wait_for_unit("prometheus-unbound-exporter.service")
+ wait_for_open_port(9167)
+ succeed("curl -sSf localhost:9167/metrics | grep -q 'unbound_up 1'")
+ '';
+ };
+
varnish = {
exporterConfig = {
enable = true;
diff --git a/pkgs/servers/monitoring/prometheus/unbound-exporter.nix b/pkgs/servers/monitoring/prometheus/unbound-exporter.nix
index c085226d909..fbe530ac22c 100644
--- a/pkgs/servers/monitoring/prometheus/unbound-exporter.nix
+++ b/pkgs/servers/monitoring/prometheus/unbound-exporter.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchFromGitHub, openssl, pkg-config }:
+{ lib, rustPlatform, fetchFromGitHub, openssl, pkg-config, nixosTests }:
rustPlatform.buildRustPackage rec {
pname = "unbound-telemetry";
@@ -17,6 +17,8 @@ rustPlatform.buildRustPackage rec {
buildInputs = [ openssl ];
+ passthru.tests = { inherit (nixosTests.prometheus-exporters) unbound; };
+
meta = with lib; {
description = "Prometheus exporter for Unbound DNS resolver";
homepage = "https://github.com/svartalf/unbound-telemetry";
nixos/modules/services/monitoring/prometheus/exporters/unbound.nix
Outdated
Show resolved
Hide resolved
nixos/modules/services/monitoring/prometheus/exporters/unbound.nix
Outdated
Show resolved
Hide resolved
40f6b0f
to
8b2117e
Compare
Author: WilliButz <willibutz@posteo.de>
f549134
to
d3fe53a
Compare
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)