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