1{ config, lib, pkgs, options }:
2
3let
4 cfg = config.services.prometheus.exporters.graphite;
5 format = pkgs.formats.yaml { };
6in
7{
8 port = 9108;
9 extraOpts = {
10 graphitePort = lib.mkOption {
11 type = lib.types.port;
12 default = 9109;
13 description = lib.mdDoc ''
14 Port to use for the graphite server.
15 '';
16 };
17 mappingSettings = lib.mkOption {
18 type = lib.types.submodule {
19 freeformType = format.type;
20 options = { };
21 };
22 default = { };
23 description = lib.mdDoc ''
24 Mapping configuration for the exporter, see
25 <https://github.com/prometheus/graphite_exporter#yaml-config> for
26 available options.
27 '';
28 };
29 };
30 serviceOpts = {
31 serviceConfig = {
32 ExecStart = ''
33 ${pkgs.prometheus-graphite-exporter}/bin/graphite_exporter \
34 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
35 --graphite.listen-address ${cfg.listenAddress}:${toString cfg.graphitePort} \
36 --graphite.mapping-config ${format.generate "mapping.yml" cfg.mappingSettings} \
37 ${lib.concatStringsSep " \\\n " cfg.extraFlags}
38 '';
39 };
40 };
41}