From 28b1639d57908bac1ccbaf1b450ad66e7480814c Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 2 Apr 2025 16:00:07 +0100 Subject: [PATCH] nixos/grafana-agent: remove As described in https://github.com/NixOS/nixpkgs/pull/394017, grafana-agent does not build with Go 1.23 anymore, and Go 1.22 has been removed. grafana-agent has been deprecated by Grafana (in favour of Grafana Alloy), and will be EOL on 2025-11-01, which would be part of the upcoming 25.05 release. Instead of leaving us with a broken package, drop it alltogether, and add release notes. --- doc/release-notes/rl-2505.section.md | 6 + nixos/modules/module-list.nix | 1 - nixos/modules/rename.nix | 7 + .../services/monitoring/grafana-agent.nix | 180 ------------------ nixos/tests/all-tests.nix | 1 - nixos/tests/grafana-agent.nix | 34 ---- pkgs/by-name/gr/grafana-agent/package.nix | 136 ------------- pkgs/top-level/aliases.nix | 1 + 8 files changed, 14 insertions(+), 352 deletions(-) delete mode 100644 nixos/modules/services/monitoring/grafana-agent.nix delete mode 100644 nixos/tests/grafana-agent.nix delete mode 100644 pkgs/by-name/gr/grafana-agent/package.nix diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index e030606cbdc4..aafb5f3918f9 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -54,6 +54,12 @@ - [testers.shellcheck](https://nixos.org/manual/nixpkgs/unstable/#tester-shellcheck) now warns when `name` is not provided. The `name` argument will become mandatory in a future release. +- `grafana-agent` and `services.grafana-agent` have been removed in favor of + Grafana Alloy (`grafana-alloy` and `services.alloy`), as they depend on an EOL compiler version + and will become EOL during the 25.05 lifecycle. + Grafana recommends migrating to `grafana-alloy` (`services.alloy`). + See https://grafana.com/docs/alloy/latest/set-up/migrate/ for details. + - `xdragon` package has been renamed to `dragon-drop`. `xdragon` is an alias to `dragon-drop` and the package still provides `bin/xdragon`. `bin/dragon` is no longer supplied. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 2bcd9b90c178..0ddef5fc0198 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -949,7 +949,6 @@ ./services/monitoring/glances.nix ./services/monitoring/glpi-agent.nix ./services/monitoring/goss.nix - ./services/monitoring/grafana-agent.nix ./services/monitoring/grafana-image-renderer.nix ./services/monitoring/grafana-reporter.nix ./services/monitoring/grafana-to-ntfy.nix diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 4f1565dc6298..49872bc7a96b 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -143,6 +143,13 @@ in ] "The fourStoreEndpoint module has been removed") (mkRemovedOptionModule [ "services" "fprot" ] "The corresponding package was removed from nixpkgs.") (mkRemovedOptionModule [ "services" "frab" ] "The frab module has been removed") + (mkRemovedOptionModule + [ + "services" + "grafana-agent" + ] + "The grafana-agent module has been removed. Consider migrating to `grafana-alloy` (`services.alloy.enable`). See " + ) (mkRemovedOptionModule [ "services" "homeassistant-satellite" ] "The `services.homeassistant-satellite` module has been replaced by `services.wyoming-satellite`." ) diff --git a/nixos/modules/services/monitoring/grafana-agent.nix b/nixos/modules/services/monitoring/grafana-agent.nix deleted file mode 100644 index f00514d61936..000000000000 --- a/nixos/modules/services/monitoring/grafana-agent.nix +++ /dev/null @@ -1,180 +0,0 @@ -{ - lib, - pkgs, - config, - generators, - ... -}: -let - cfg = config.services.grafana-agent; - settingsFormat = pkgs.formats.yaml { }; - configFile = settingsFormat.generate "grafana-agent.yaml" cfg.settings; -in -{ - meta = { - maintainers = with lib.maintainers; [ - flokli - zimbatm - ]; - }; - - options.services.grafana-agent = { - enable = lib.mkEnableOption "grafana-agent"; - - package = lib.mkPackageOption pkgs "grafana-agent" { }; - - credentials = lib.mkOption { - description = '' - Credentials to load at service startup. Keys that are UPPER_SNAKE will be loaded as env vars. Values are absolute paths to the credentials. - ''; - type = lib.types.attrsOf lib.types.str; - default = { }; - - example = { - logs_remote_write_password = "/run/keys/grafana_agent_logs_remote_write_password"; - LOGS_REMOTE_WRITE_URL = "/run/keys/grafana_agent_logs_remote_write_url"; - LOGS_REMOTE_WRITE_USERNAME = "/run/keys/grafana_agent_logs_remote_write_username"; - metrics_remote_write_password = "/run/keys/grafana_agent_metrics_remote_write_password"; - METRICS_REMOTE_WRITE_URL = "/run/keys/grafana_agent_metrics_remote_write_url"; - METRICS_REMOTE_WRITE_USERNAME = "/run/keys/grafana_agent_metrics_remote_write_username"; - }; - }; - - extraFlags = lib.mkOption { - type = with lib.types; listOf str; - default = [ ]; - example = [ - "-enable-features=integrations-next" - "-disable-reporting" - ]; - description = '' - Extra command-line flags passed to {command}`grafana-agent`. - - See - ''; - }; - - settings = lib.mkOption { - description = '' - Configuration for {command}`grafana-agent`. - - See - ''; - - type = lib.types.submodule { - freeformType = settingsFormat.type; - }; - - default = { }; - defaultText = lib.literalExpression '' - { - metrics = { - wal_directory = "\''${STATE_DIRECTORY}"; - global.scrape_interval = "5s"; - }; - integrations = { - agent.enabled = true; - agent.scrape_integration = true; - node_exporter.enabled = true; - }; - } - ''; - example = { - metrics.global.remote_write = [ - { - url = "\${METRICS_REMOTE_WRITE_URL}"; - basic_auth.username = "\${METRICS_REMOTE_WRITE_USERNAME}"; - basic_auth.password_file = "\${CREDENTIALS_DIRECTORY}/metrics_remote_write_password"; - } - ]; - logs.configs = [ - { - name = "default"; - scrape_configs = [ - { - job_name = "journal"; - journal = { - max_age = "12h"; - labels.job = "systemd-journal"; - }; - relabel_configs = [ - { - source_labels = [ "__journal__systemd_unit" ]; - target_label = "systemd_unit"; - } - { - source_labels = [ "__journal__hostname" ]; - target_label = "nodename"; - } - { - source_labels = [ "__journal_syslog_identifier" ]; - target_label = "syslog_identifier"; - } - ]; - } - ]; - positions.filename = "\${STATE_DIRECTORY}/loki_positions.yaml"; - clients = [ - { - url = "\${LOGS_REMOTE_WRITE_URL}"; - basic_auth.username = "\${LOGS_REMOTE_WRITE_USERNAME}"; - basic_auth.password_file = "\${CREDENTIALS_DIRECTORY}/logs_remote_write_password"; - } - ]; - } - ]; - }; - }; - }; - - config = lib.mkIf cfg.enable { - services.grafana-agent.settings = { - # keep this in sync with config.services.grafana-agent.settings.defaultText. - metrics = { - wal_directory = lib.mkDefault "\${STATE_DIRECTORY}"; - global.scrape_interval = lib.mkDefault "5s"; - }; - integrations = { - agent.enabled = lib.mkDefault true; - agent.scrape_integration = lib.mkDefault true; - node_exporter.enabled = lib.mkDefault true; - }; - }; - - systemd.services.grafana-agent = { - wantedBy = [ "multi-user.target" ]; - script = '' - set -euo pipefail - shopt -u nullglob - - # Load all credentials into env if they are in UPPER_SNAKE form. - if [[ -n "''${CREDENTIALS_DIRECTORY:-}" ]]; then - for file in "$CREDENTIALS_DIRECTORY"/*; do - key=$(basename "$file") - if [[ $key =~ ^[A-Z0-9_]+$ ]]; then - echo "Environ $key" - export "$key=$(< "$file")" - fi - done - fi - - # We can't use Environment=HOSTNAME=%H, as it doesn't include the domain part. - export HOSTNAME=$(< /proc/sys/kernel/hostname) - - exec ${lib.getExe cfg.package} -config.expand-env -config.file ${configFile} ${lib.escapeShellArgs cfg.extraFlags} - ''; - serviceConfig = { - Restart = "always"; - DynamicUser = true; - RestartSec = 2; - SupplementaryGroups = [ - # allow to read the systemd journal for loki log forwarding - "systemd-journal" - ]; - StateDirectory = "grafana-agent"; - LoadCredential = lib.mapAttrsToList (key: value: "${key}:${value}") cfg.credentials; - Type = "simple"; - }; - }; - }; -} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0d75a616e23a..2458c1889fcc 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -546,7 +546,6 @@ in gotify-server = handleTest ./gotify-server.nix { }; gotosocial = runTest ./web-apps/gotosocial.nix; grafana = handleTest ./grafana { }; - grafana-agent = handleTest ./grafana-agent.nix { }; graphite = handleTest ./graphite.nix { }; grav = runTest ./web-apps/grav.nix; graylog = handleTest ./graylog.nix { }; diff --git a/nixos/tests/grafana-agent.nix b/nixos/tests/grafana-agent.nix deleted file mode 100644 index 05e3764583f3..000000000000 --- a/nixos/tests/grafana-agent.nix +++ /dev/null @@ -1,34 +0,0 @@ -import ./make-test-python.nix ( - { lib, pkgs, ... }: - - let - nodes = { - machine = { - services.grafana-agent = { - enable = true; - }; - }; - }; - in - { - name = "grafana-agent"; - - meta = with lib.maintainers; { - maintainers = [ zimbatm ]; - }; - - inherit nodes; - - testScript = '' - start_all() - - with subtest("Grafana-agent is running"): - machine.wait_for_unit("grafana-agent.service") - machine.wait_for_open_port(12345) - machine.succeed( - "curl -sSfN http://127.0.0.1:12345/-/healthy" - ) - machine.shutdown() - ''; - } -) diff --git a/pkgs/by-name/gr/grafana-agent/package.nix b/pkgs/by-name/gr/grafana-agent/package.nix deleted file mode 100644 index ee5b17b77cd3..000000000000 --- a/pkgs/by-name/gr/grafana-agent/package.nix +++ /dev/null @@ -1,136 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, - fetchYarnDeps, - fixup-yarn-lock, - grafana-agent, - nix-update-script, - nixosTests, - nodejs, - stdenv, - systemd, - testers, - yarn, -}: - -buildGoModule rec { - pname = "grafana-agent"; - version = "0.44.2"; - - src = fetchFromGitHub { - owner = "grafana"; - repo = "agent"; - tag = "v${version}"; - hash = "sha256-dAfiTJ0DlChriYOl/bPCEHj/UpbZ2a8BZBCQ82H+O9I="; - }; - - vendorHash = "sha256-6nXUeRpaezzfRykqMCtwP0FQZchRdxLmtupVAMNAjmY="; - proxyVendor = true; # darwin/linux hash mismatch - - frontendYarnOfflineCache = fetchYarnDeps { - yarnLock = src + "/internal/web/ui/yarn.lock"; - hash = "sha256-uqKOGSEnR9CU4vlahldrLxDb3z7Yt1DebyRB91NQMRc="; - }; - - ldflags = - let - prefix = "github.com/grafana/agent/internal/build"; - in - [ - "-s" - "-w" - # https://github.com/grafana/agent/blob/v0.44.2/Makefile#L132-L137 - "-X ${prefix}.Version=${version}" - "-X ${prefix}.Branch=v${version}" - "-X ${prefix}.Revision=v${version}" - "-X ${prefix}.BuildUser=nix" - "-X ${prefix}.BuildDate=1980-01-01T00:00:00Z" - ]; - - nativeBuildInputs = [ - fixup-yarn-lock - nodejs - yarn - ]; - - tags = [ - "builtinassets" - "nonetwork" - "nodocker" - "promtail_journal_enabled" - ]; - - subPackages = [ - "cmd/grafana-agent" - "cmd/grafana-agentctl" - "internal/web/ui" - ]; - - preBuild = '' - export HOME="$TMPDIR" - - pushd internal/web/ui - fixup-yarn-lock yarn.lock - yarn config --offline set yarn-offline-mirror $frontendYarnOfflineCache - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - patchShebangs node_modules - yarn --offline run build - popd - ''; - - # do not pass preBuild to go-modules.drv, as it would otherwise fail to build. - # but even if it would work, it simply isn't needed in that scope. - overrideModAttrs = ( - _: { - preBuild = null; - } - ); - - # uses go-systemd, which uses libsystemd headers - # https://github.com/coreos/go-systemd/issues/351 - env.NIX_CFLAGS_COMPILE = toString ( - lib.optionals stdenv.hostPlatform.isLinux [ "-I${lib.getDev systemd}/include" ] - ); - - # go-systemd uses libsystemd under the hood, which does dlopen(libsystemd) at - # runtime. - # Add to RUNPATH so it can be found. - postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - patchelf \ - --set-rpath "${ - lib.makeLibraryPath [ (lib.getLib systemd) ] - }:$(patchelf --print-rpath $out/bin/grafana-agent)" \ - $out/bin/grafana-agent - ''; - - passthru = { - tests = { - inherit (nixosTests) grafana-agent; - version = testers.testVersion { - inherit version; - command = "${lib.getExe grafana-agent} --version"; - package = grafana-agent; - }; - }; - updateScript = nix-update-script { }; - # alias for nix-update to be able to find and update this attribute - offlineCache = frontendYarnOfflineCache; - }; - - meta = { - description = "Lightweight subset of Prometheus and more, optimized for Grafana Cloud"; - license = lib.licenses.asl20; - homepage = "https://grafana.com/products/cloud"; - changelog = "https://github.com/grafana/agent/blob/${src.rev}/CHANGELOG.md"; - maintainers = with lib.maintainers; [ - flokli - emilylange - ]; - mainProgram = "grafana-agent"; - # Breaks with Go 1.23: https://github.com/grafana/agent/issues/6972 - # Binary panics at runtime with: - # 'panic: pattern "GET /debug/pprof/" (registered at net/http/pprof/pprof.go:100) conflicts with pattern "/debug/pprof/delta_heap"' - broken = true; - }; -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 7808fc468fef..81c4659eb764 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -747,6 +747,7 @@ mapAliases { gobby5 = throw "'gobby5' has been renamed to/replaced by 'gobby'"; # Converted to throw 2024-10-17 gradle_6 = throw "Gradle 6 has been removed, as it is end-of-life (https://endoflife.date/gradle) and has many vulnerabilities that are not resolved until Gradle 7."; # Added 2024-10-30 gradle_6-unwrapped = throw "Gradle 6 has been removed, as it is end-of-life (https://endoflife.date/gradle) and has many vulnerabilities that are not resolved until Gradle 7."; # Added 2024-10-30 + grafana-agent = throw "'grafana-agent' has been removed, as it only works with an EOL compiler and will become EOL during the 25.05 release. Consider migrating to 'grafana-alloy' instead"; # Added 2025-04-02 #godot