Skip to content
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

Backport prometheus2 to release-19.03 #59262

Merged
merged 15 commits into from Apr 16, 2019

Conversation

basvandijk
Copy link
Member

@basvandijk basvandijk commented Apr 10, 2019

Motivation for this change

I would like to use Prometheus-2 on the upcoming 19.03 release. @jbgi also expressed a desire for this.

This backports PRs #58255, #59175 and #59182 to release-19.03.

It also includes a note about this in the 19.03 release notes.

@samueldr @lheckemann this mainly involves the addition of the new services.prometheus2 module. However, there's one minor backwards incompatibility: the option services.prometheus.dataDir is now required to have /var/lib/ as a prefix. Note that it defaulted and still defaults to /var/lib/prometheus. This is also documented in the 19.03 release notes. I think it's safe to merge.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

jbgi and others added 15 commits April 10, 2019 13:49
 So that people can easily try newer prometheus version
 in overlays:

 self: super: {
   prometheus_2 = (super.callPackage <nixpkgs/pkgs/servers/monitoring/prometheus> {}).generic {
     version = "2.8.1";
     sha256 = "0x8w0qdh4lcf19nmdlhvgzpy08c2a932d3k49cjwhi5npcsf858n";
     doCheck = false;
   };
 }

(cherry picked from commit 670359e)
Since the `generic` function is now exported it should have a less
generic name, pun intended.

(cherry picked from commit b6fdd1a)
As the configuration for the exporters and alertmanager is unchanged
between the two major versions this patch tries to minimize
duplication while at the same time as there's no upgrade path from 1.x
to 2.x, it allows running the two services in parallel. See also NixOS#56037

(cherry picked from commit 11b8972)
(cherry picked from commit 1b6ce80)
This uses fewer lines of code and one less process.

(cherry picked from commit a59c929)
Previously the prometheus.service file looked like:

  ExecStart=/nix/store/wjkhfw3xgkmavz1akkqir99w4lbqhak7-prometheus-1.8.2-bin/bin/prometheus -storage.local.path=/var/lib/prometheus/metrics \
    -config.file=/nix/store/zsnvzw51mk3n1cxjd0351bj39k1j6j27-prometheus.yml-check-config-checked \
    -web.listen-address=0.0.0.0:9090 \
    -alertmanager.notification-queue-capacity=10000 \
    -alertmanager.timeout=10s \
     \

  Restart=always

Now it's:

  ExecStart=/nix/store/wjkhfw3xgkmavz1akkqir99w4lbqhak7-prometheus-1.8.2-bin/bin/prometheus \
    -storage.local.path=/var/lib/prometheus/metrics \
    -config.file=/nix/store/zsnvzw51mk3n1cxjd0351bj39k1j6j27-prometheus.yml-check-config-checked \
    -web.listen-address=0.0.0.0:9090 \
    -alertmanager.notification-queue-capacity=10000 \
    -alertmanager.timeout=10s
  Restart=always

(cherry picked from commit 7cf27fe)
This is to ensure more backwards compatibility. Note this is not 100%
backwards compatible because we now require dataDir to begin with /var/lib/.

(cherry picked from commit c95179b)
@basvandijk
Copy link
Member Author

@GrahamcOfBorg test prometheus prometheus2

@basvandijk basvandijk merged commit 012e05a into NixOS:release-19.03 Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants