2024-08-23 17:42:17 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkIf;
|
|
|
|
cfg = config.bagel.services.pyroscope;
|
2024-08-23 19:04:22 +00:00
|
|
|
pyroscopePort = config.services.pyroscope.settings.server.http_listen_port;
|
2024-08-23 17:42:17 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.bagel.services.pyroscope = {
|
|
|
|
enable = mkEnableOption "pyroscope server";
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: send me to nixpkgs
|
|
|
|
imports = [
|
|
|
|
./module.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-08-23 18:19:55 +00:00
|
|
|
age.secrets.pyroscope-secrets.file = ../../../secrets/pyroscope-secrets.age;
|
2024-08-23 19:04:22 +00:00
|
|
|
services.nginx = {
|
|
|
|
upstreams.pyroscope = {
|
|
|
|
servers."127.0.0.1:${toString pyroscopePort}" = {};
|
|
|
|
extraConfig = "keepalive 16;";
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualHosts."pyroscope.forkos.org" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2024-08-24 06:45:20 +00:00
|
|
|
locations."/ingest" = {
|
2024-08-23 19:04:22 +00:00
|
|
|
proxyPass = "http://pyroscope";
|
|
|
|
basicAuthFile = config.age.secrets.metrics-push-htpasswd.path;
|
|
|
|
};
|
2024-08-24 08:33:49 +00:00
|
|
|
locations."/push.v1.PusherService/Push" = {
|
|
|
|
proxyPass = "http://pyroscope";
|
|
|
|
basicAuthFile = config.age.secrets.metrics-push-htpasswd.path;
|
|
|
|
};
|
2024-08-23 19:04:22 +00:00
|
|
|
};
|
|
|
|
};
|
2024-08-23 18:19:55 +00:00
|
|
|
services.pyroscope = {
|
|
|
|
enable = true;
|
|
|
|
secretFile = config.age.secrets.pyroscope-secrets.path;
|
|
|
|
settings = {
|
|
|
|
target = "all";
|
|
|
|
multitenancy_enabled = false;
|
|
|
|
|
|
|
|
api.base-url = "https://pyroscope.forkos.org";
|
|
|
|
analytics.reporting_enabled = false;
|
|
|
|
|
|
|
|
storage = {
|
|
|
|
backend = "s3";
|
|
|
|
s3 = {
|
|
|
|
endpoint = "s3.delroth.net";
|
|
|
|
region = "garage";
|
|
|
|
bucket_name = "bagel-pyroscope";
|
|
|
|
access_key_id = "\${S3_KEY_ID}";
|
|
|
|
secret_access_key = "\${S3_KEY}";
|
|
|
|
force_path_style = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
server = {
|
2024-08-23 19:04:22 +00:00
|
|
|
http_listen_port = 4040;
|
2024-08-23 18:19:55 +00:00
|
|
|
grpc_listen_port = 9097;
|
|
|
|
grpc_server_max_recv_msg_size = 104857600;
|
|
|
|
grpc_server_max_send_msg_size = 104857600;
|
|
|
|
grpc_server_max_concurrent_streams = 1000;
|
|
|
|
};
|
|
|
|
|
|
|
|
memberlist = {
|
|
|
|
advertise_port = 7948;
|
|
|
|
bind_port = 7948;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-08-23 17:42:17 +00:00
|
|
|
};
|
|
|
|
}
|