blob: a887f91fb2d30495173ad5f02d38fa6bc79782c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# TODO: submit burningalchemist's sql_exporter to nixpkgs
{ config, lib, pkgs, ... }:
let
sqlExporter = pkgs.callPackage ./default.nix {};
cfg = config.services.prometheus-sql-exporter;
configFile = builtins.toFile "config.yaml" (builtins.toJSON cfg.config);
in
{
options.services.prometheus-sql-exporter = {
enable = lib.mkEnableOption "sql-exporter";
port = lib.mkOption {
type = lib.types.int;
};
config = lib.mkOption {
type = (pkgs.formats.json {}).type;
};
};
config = lib.mkIf cfg.enable {
systemd.services.prometheus-sql-exporter = {
serviceConfig = {
ExecStart = "${sqlExporter}/bin/sql_exporter -config.file ${configFile} -web.listen-address :${toString cfg.port}";
DynamicUser = "true";
User = "prometheus-sql-exporter";
};
wantedBy = ["multi-user.target"];
};
};
}
|