export and scrape dibbler prometheus stats #143

Open
vegardbm wants to merge 1 commits from dibbler-prometheus into main
2 changed files with 53 additions and 0 deletions
@@ -8,6 +8,7 @@ in {
./matrix-synapse.nix
./mysqld.nix
./postgres.nix
./dibbler.nix
];
services.prometheus = {
@@ -0,0 +1,52 @@
{ ... }:
{
services.prometheus.scrapeConfigs = [{
job_name = "sql_exporter";
scrape_interval = "1m";
scheme = "http";
static_configs = [{
targets = [ "localhost:9237" ];
}];
}];
services.prometheus.exporters.sql = {
enable = true;
configuration = {
jobs.dibbler = {
interval = "1m";
connections = [
"postgres://pvv_vv:WP97&amDp&*gfhg3TyR8@postgres.pvv.ntnu.no"
Review

bro...

bro...
Review

lol, lmao even

lol, lmao even
];
queries."daily_purchase_sum" = {
help = "Sum of purchases for the current day.";
labels = [ "thing" ];
values = [ "sum" ];
query = "SELECT SUM(price) FROM purchases GROUP BY DATE(time) ORDER BY DATE(time) DESC LIMIT 1";
Review

I have a feeling this is just stupid and inefficient. There should be no reason to sort this. It does work tho.

I have a feeling this is just stupid and inefficient. There should be no reason to sort this. It does work tho.
};
queries."total_purchase_sum" = {
help = "Sum of all purchases.";
labels = [ "thing" ];
values = [ "sum" ];
query = " SELECT SUM(price) FROM purchases";
};
queries."total_stock_value" = {
help = "The value of all stock in dibbler.";
labels = [ "thing" ];
values = [ "sum" ];
query = "
SELECT SUM(price * stock) FROM products";
};
queries."user_credit_sum" = {
help = "The sum of all user credit.";
labels = [ "thing" ];
values = [ "sum" ];
query = "SELECT SUM(credit) FROM users";
};
};
};
};
}