mirror of
https://github.com/Noratrieb/vps.git
synced 2026-01-14 16:55:00 +01:00
hilarious hack to get std.noratrieb.dev deployments monitored
This commit is contained in:
parent
db714febbf
commit
9856757b52
2 changed files with 52 additions and 0 deletions
|
|
@ -45,9 +45,23 @@
|
|||
job_name = "pretense";
|
||||
static_configs = [{ targets = map (name: "${name}.local:9150") (builtins.attrNames networkingConfig); }];
|
||||
}
|
||||
{
|
||||
job_name = "std-internal-docs-status";
|
||||
scrape_interval = "1h";
|
||||
static_configs = [{ targets = [ "localhost:7846" ]; }];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services.prometheus-exporter-std-internal-docs-status = {
|
||||
description = "Cursed hack to get the GitHub deployment status of std.noratrieb.dev";
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
ExecStart = "${lib.getExe pkgs.nodejs_24} ${./prometheus-exporter-std-internal-docs.mjs}";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
age.secrets.grafana_admin_password.file = ../../secrets/grafana_admin_password.age;
|
||||
systemd.services.grafana.serviceConfig.EnvironmentFile = config.age.secrets.grafana_admin_password.path;
|
||||
services.grafana = {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
import http from "node:http";
|
||||
|
||||
const server = http.createServer();
|
||||
server
|
||||
.on("request", (req, res) => {
|
||||
fetch(
|
||||
"https://api.github.com/repos/Noratrieb/std-internal-docs/deployments"
|
||||
)
|
||||
.then(async (res) => {
|
||||
console.log(`Received response from GitHub: ${res.status}`);
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
console.error(
|
||||
`Received error from GitHub: ${res.status}: ${await res.text()}`
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((body) => {
|
||||
console.log(`Received body from GitHub`);
|
||||
const time =
|
||||
body?.[0]?.created_at && new Date(body[0].created_at).getTime();
|
||||
res
|
||||
.writeHead(time ? 200 : 500, {
|
||||
"Content-Type":
|
||||
"text/plain; version=0.0.4; charset=utf-8; escaping=underscores",
|
||||
})
|
||||
.end(
|
||||
time
|
||||
? `std_internal_docs_last_deployment ${time}\n` +
|
||||
`std_internal_docs_last_deployment_age ${new Date().getTime() - time}\n`
|
||||
: undefined
|
||||
);
|
||||
});
|
||||
})
|
||||
.listen(7846, "127.0.0.1", () => {
|
||||
console.log("Started the std.noratrieb.dev status exporter, lol");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue