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
services/prometheus/exporters: add scaphandre #239803
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ let | |
"redis" | ||
"rspamd" | ||
"rtl_433" | ||
"scaphandre" | ||
"script" | ||
"shelly" | ||
"snmp" | ||
|
@@ -301,6 +302,21 @@ in | |
Please specify either 'services.prometheus.exporters.sql.configuration' or | ||
'services.prometheus.exporters.sql.configFile' | ||
''; | ||
} { | ||
assertion = cfg.scaphandre.enable -> (pkgs.stdenv.hostPlatform.isx86_64 == true); | ||
message = '' | ||
Only x86_64 host platform architecture is not supported. | ||
''; | ||
} { | ||
assertion = cfg.scaphandre.enable -> ((lib.kernel.whenHelpers pkgs.linux.version).whenOlder "5.11" true).condition == false; | ||
message = '' | ||
A kernel version newer than '5.11' is required. ${pkgs.linux.version} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should explain that the assertion comes from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ambroisie Is there any convention to explain that if comes from a specific config? |
||
''; | ||
} { | ||
assertion = cfg.scaphandre.enable -> (builtins.elem "intel_rapl_common" config.boot.kernelModules); | ||
message = '' | ||
Please enable 'intel_rapl_common' in 'boot.kernelModules'. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I should also assert that machine runs on Intel or AMD according to the compatibility page but I don't know how to do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to restrict as much as possible the possibility to use Scaphandre without having the proper configuration. |
||
} ] ++ (flip map (attrNames exporterOpts) (exporter: { | ||
assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall; | ||
message = '' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ config | ||
, lib | ||
, pkgs | ||
, options | ||
}: | ||
|
||
let | ||
logPrefix = "services.prometheus.exporter.scaphandre"; | ||
cfg = config.services.prometheus.exporters.scaphandre; | ||
in { | ||
port = 8080; | ||
extraOpts = { | ||
telemetryPath = lib.mkOption { | ||
type = lib.types.str; | ||
default = "/metrics"; | ||
description = lib.mdDoc '' | ||
Path under which to expose metrics. | ||
''; | ||
}; | ||
}; | ||
|
||
serviceOpts = { | ||
serviceConfig = { | ||
ExecStart = '' | ||
${pkgs.scaphandre}/bin/scaphandre prometheus \ | ||
--address ${cfg.listenAddress} \ | ||
--port ${toString cfg.port} \ | ||
--suffix ${cfg.telemetryPath} \ | ||
${lib.concatStringsSep " \\\n " cfg.extraFlags} | ||
''; | ||
}; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1085,6 +1085,22 @@ let | |
''; | ||
}; | ||
|
||
scaphandre = { | ||
exporterConfig = { | ||
enable = true; | ||
}; | ||
metricProvider = { | ||
boot.kernelModules = [ "intel_rapl_common" ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently this option will fail on the CI but it does not fail on my host even if ran in QEMU. I added an assertion to make sure it is added explicitly by the user but it seems scaphandre does not produce any error if it is not "really" probed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}; | ||
exporterTest = '' | ||
wait_for_unit("prometheus-scaphandre-exporter.service") | ||
wait_for_open_port(8080) | ||
wait_until_succeeds( | ||
"curl -sSf 'localhost:8080/metrics'" | ||
) | ||
''; | ||
}; | ||
|
||
shelly = { | ||
exporterConfig = { | ||
enable = true; | ||
|
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.
I think you meant
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.
And are you sure the (build) host should be x86_64? Or do you mean the (build) target, i.e: the machine that will run the code?
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.
Well I mean the build target indeed.