-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
nixos/prometheus: abbility to add downstream exporters #298171
base: master
Are you sure you want to change the base?
Conversation
38393f8
to
b2a6008
Compare
fa4e0bd
to
8b85385
Compare
8b85385
to
aa09415
Compare
aa09415
to
8deb9e4
Compare
imports = [ | ||
(import "${modulesPath}/services/monitoring/prometheus/mk-downstream-exporter.nix" { | ||
name = "EXPORTER"; | ||
file = ./EXPORTER-exporter.nix; |
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.
Why does this need to be passed via a file? Being able to pass that inline seems useful, at least for exporters with little-to-no configurability; it seems better from a readability standpoint, than having to jump files (and mental contexts) to get potentially-little information.
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.
Current exporters are also files, this fits the pattern.
I could extend it to take a function too and call the option "module" therefore keeping it similar to how "imports" works right now
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.
Current exporters are also files, this fits the pattern.
I'm not saying it's necessarily wrong to put it in a separate file, especially in the current case: folder full of exporters, which the module automatically maps through mkExporter
. However, I think it would be pretty natural to either take in an already-resolved attrset, or a function (taking pkgs
, lib
, etc.)
Importing the file can be the responsibility of the caller then, which leaves them the ability to implement whatever conventions they use; for instance, if something ships a bunch of exporters which use a common configuration format (incl. cmdline parameters) the drv's author may want to automate the option and service definitions, which seems simpler to do if they can programatically generate that part before passing it to mkExporter
.
(In principle it's entirely possible to do the same thing with pass-by-file, using IFD, but that gets kind of gnarly.)
```nix | ||
{ modulesPath, ... }: { | ||
imports = [ | ||
(import "${modulesPath}/services/monitoring/prometheus/mk-downstream-exporter.nix" { |
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.
Could this be exposed under utils
or such, instead of hardcoding that path in every caller?
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.
Does it fit there? Certainly could be done
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.
Seems useful, but I had a couple questions about the proposed implementation.
8deb9e4
to
b9c2d3e
Compare
9da240c
to
d8f28e9
Compare
d8f28e9
to
9b47fa1
Compare
9b47fa1
to
0f6aaad
Compare
Description of changes
This adds the abbility to add downstream exporters while profiting from upstream's exporter config generator
Documentation of the new method: https://github.com/mgit-at/nixpkgs/blob/downstream-exporter/nixos/modules/services/monitoring/prometheus/exporters.md#adding-a-downstream-exporter-module-services-prometheus-exporters-downstream-exporter
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.