let
  port = 9008;
in {
  services.prometheus.scrapeConfigs = [{
    job_name = "synapse";
    metrics_path = "/_synapse/metrics";
    static_configs = [{
      targets = ["localhost:${toString port}"];
    }];
  }];
  services.matrix-synapse.settings = {
    enable_metrics = true;
    listeners = [
      {
        port = port;
        type = "metrics";
        bind_addresses = ["127.0.0.1"];
        tls = false;
        resources = []; # unneeded with type: metrics, just to make the nix module happy
      }
    ];
  };
# Grafana rules? 
# https://github.com/element-hq/synapse/tree/master/contrib/prometheus/
}
