Skip to content

Commit

Permalink
[nyarlathotep] Switch from promscale to VictoriaMetrics
Browse files Browse the repository at this point in the history
Promscale was discontinued early last year, and around the beginning of
this year developed the irritating problem of frequently dropping data,
which led to me looking at the dashboard less and less often.

I tried using the prometheus backfilling tool, but couldn't get it to
work - it apparently loaded everything without error, but the metrics
just weren't there.  It also took 10m+ to load my historic hledger data,
which is far worse than the few seconds promscale took.

Today I found VictoriaMetrics, which falls into the same sweet spot as
promscale: it has an API that supports deleting timeseries and loading
data with arbitrary timestamps, and supports the prometheus query
language.  It works really well so far, and I've got my dashboard
working again!
  • Loading branch information
barrucadu committed Oct 17, 2024
1 parent 4355666 commit ce43e04
Show file tree
Hide file tree
Showing 3 changed files with 84 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 ce43e04

Please sign in to comment.