feat(monitoring): add pyroscope to the infrastructure
Vendored for the time being. See https://cl.forkos.org/c/nixpkgs/+/181 for upstreaming properly. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
c380f29937
commit
db46b01ae9
|
@ -23,6 +23,7 @@
|
|||
bagel.services.loki.enable = true;
|
||||
bagel.services.grafana.enable = true;
|
||||
bagel.services.grapevine.enable = true;
|
||||
bagel.services.pyroscope.enable = true;
|
||||
bagel.services.hookshot = {
|
||||
enable = true;
|
||||
admins = [
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
(final: prev: {
|
||||
iusb-spoof = final.callPackage ./iusb-spoof.nix {};
|
||||
u-root = final.callPackage ./u-root {};
|
||||
pyroscope = final.callPackage ./pyroscope {};
|
||||
})
|
||||
]
|
||||
|
|
42
overlays/pyroscope/default.nix
Normal file
42
overlays/pyroscope/default.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ lib
|
||||
, buildGoModule
|
||||
, fetchFromGitHub
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "pyroscope";
|
||||
version = "1.7.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "grafana";
|
||||
repo = "pyroscope";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-iMP67J0Q8Cgo52iImMzAM3PEkk6uLF7r6v9TyXZVaIE=";
|
||||
};
|
||||
|
||||
env.GOWORK = "off";
|
||||
|
||||
vendorHash = "sha256-ggntpnU9s2rpkv6S0LnZNexrdkBsdsUrGPc93SVrK4M=";
|
||||
|
||||
subPackages = [ "cmd/profilecli" "cmd/pyroscope" ];
|
||||
|
||||
ldflags = [
|
||||
"-extldflags"
|
||||
"-static"
|
||||
"-s"
|
||||
"-w"
|
||||
"-X=github.com/grafana/pyroscope/pkg/util/build.Branch=${src.rev}"
|
||||
"-X=github.com/grafana/pyroscope/pkg/util/build.Version=${version}"
|
||||
"-X=github.com/grafana/pyroscope/pkg/util/build.Revision=${src.rev}"
|
||||
"-X=github.com/grafana/pyroscope/pkg/util/build.BuildDate=1970-01-01T00:00:00Z"
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Continuous profiling platform";
|
||||
homepage = "https://github.com/grafana/pyroscope";
|
||||
changelog = "https://github.com/grafana/pyroscope/blob/${src.rev}/CHANGELOG.md";
|
||||
license = licenses.agpl3Only;
|
||||
maintainers = with maintainers; [ raitobezarius ];
|
||||
mainProgram = "pyroscope";
|
||||
};
|
||||
}
|
|
@ -4,5 +4,6 @@
|
|||
./lgtm
|
||||
./agent.nix
|
||||
./hookshot-adapter
|
||||
./pyroscope
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
19
services/monitoring/pyroscope/default.nix
Normal file
19
services/monitoring/pyroscope/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
cfg = config.bagel.services.pyroscope;
|
||||
in
|
||||
{
|
||||
options.bagel.services.pyroscope = {
|
||||
enable = mkEnableOption "pyroscope server";
|
||||
};
|
||||
|
||||
# TODO: send me to nixpkgs
|
||||
imports = [
|
||||
./module.nix
|
||||
];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.pyroscope.enable = true;
|
||||
};
|
||||
}
|
36
services/monitoring/pyroscope/module.nix
Normal file
36
services/monitoring/pyroscope/module.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkPackageOption mkOption types mkIf;
|
||||
settingsFormatYaml = pkgs.formats.yaml { };
|
||||
cfg = config.services.pyroscope;
|
||||
configFile = settingsFormatYaml.generate "settings.yaml" cfg.settings;
|
||||
in
|
||||
{
|
||||
options.services.pyroscope = {
|
||||
enable = mkEnableOption "pyroscope, a continuous profiling platform";
|
||||
package = mkPackageOption pkgs "pyroscope" { };
|
||||
settings = mkOption {
|
||||
description = "Pyroscope settings. See <>";
|
||||
|
||||
type = types.submodule {
|
||||
freeformType = settingsFormatYaml.type;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.pyroscope = {
|
||||
description = "Pyroscope server - a continuous profiling platform";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/pyroscope -config.file ${configFile}";
|
||||
WorkingDirectory = "/var/lib/pyroscope";
|
||||
User = "pyroscope";
|
||||
DynamicUser = true;
|
||||
Restart = "on-failure";
|
||||
RuntimeDirectory = "pyroscope";
|
||||
StateDirectory = "pyroscope";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue