Skip to content

Commit

Permalink
Merge pull request #305 from barrucadu/nya/vm
Browse files Browse the repository at this point in the history
[nyarlathotep] Switch from promscale to VictoriaMetrics
  • Loading branch information
barrucadu authored Oct 17, 2024
2 parents 14decc7 + c32daea commit cb989b6
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 83 deletions.
40 changes: 10 additions & 30 deletions hosts/nyarlathotep/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ with lib;
let
shares = [ "anime" "manga" "misc" "music" "movies" "tv" "torrents" ];

promscalePort = 9201;
prometheusAwairExporterPort = 9517;

httpdir = "${toString config.nixfiles.eraseYourDarlings.persistDir}/srv/http";
Expand Down Expand Up @@ -359,8 +358,8 @@ in
provision = {
datasources.settings.datasources = [
{
name = "promscale";
url = "http://localhost:${toString promscalePort}";
name = "victoriametrics";
url = "http://${config.services.victoriametrics.listenAddress}";
type = "prometheus";
}
];
Expand Down Expand Up @@ -462,46 +461,27 @@ in
};
};

systemd.services.hledger-export-to-promscale = {
description = "Export personal finance data to promscale";
systemd.services.hledger-export-to-victoriametrics = {
description = "Export personal finance data to VictoriaMetrics";
startAt = "daily";
path = with pkgs; [ hledger ];
serviceConfig = {
ExecStart =
let python = pkgs.python3.withPackages (ps: [ ps.requests ]);
in "${python}/bin/python3 ${pkgs.writeText "hledger-export-to-promscale.py" (fileContents ./jobs/hledger-export-to-promscale.py)}";
in "${python}/bin/python3 ${pkgs.writeText "hledger-export-to-victoriametrics.py" (fileContents ./jobs/hledger-export-to-victoriametrics.py)}";
User = "barrucadu";
Group = "users";
};
environment = {
LEDGER_FILE = "/home/barrucadu/s/ledger/combined.journal";
PROMSCALE_URI = "http://localhost:${toString promscalePort}";
VICTORIAMETRICS_URI = "http://${config.services.victoriametrics.listenAddress}";
};
};

nixfiles.oci-containers.pods.promscale = {
containers = {
web = {
image = "timescale/promscale:latest";
cmd = [
"-db.host=promscale-db"
"-db.name=postgres"
"-db.password=promscale"
"-db.ssl-mode=allow"
"-web.enable-admin-api=true"
"-metrics.promql.lookback-delta=168h"
];
dependsOn = [ "promscale-db" ];
ports = [{ host = promscalePort; inner = 9201; }];
};
db = {
image = "timescaledev/promscale-extension:latest-ts2-pg14";
environment = {
POSTGRES_PASSWORD = "promscale";
};
volumes = [{ name = "pgdata"; inner = "/var/lib/postgresql/data"; }];
};
};
services.victoriametrics = {
enable = true;
listenAddress = "127.0.0.1:8428";
retentionPeriod = 1200;
};


Expand Down
Loading

0 comments on commit cb989b6

Please sign in to comment.