apollo-prometheus-exporter icon indicating copy to clipboard operation
apollo-prometheus-exporter copied to clipboard

Add prefix option for metrics

Open PierrickP opened this issue 2 years ago • 1 comments

Similar to what offer prom-client for default metrics, add an option on the apollo export to add a prefix on apollo metrics

Example:

  const prometheusExporterPlugin = createPrometheusExporterPlugin({
    app,
    prefix: 'MY_PREFIX_'
  });

Will generate

MY_PREFIX_apollo_server_starting{version="v3.4.0",hostname="pierrickp-precision3551"} 1660204290.275

PierrickP avatar Aug 11 '22 07:08 PierrickP

For anyone else looking, you can just use the underlying prom-client defaultMetricsOptions to achieve this:

const apolloExporterPlugin = createPrometheusExporterPlugin({
    app,
    defaultMetricsOptions: {
        prefix: "apollo_",
    },
});

barneyjackson avatar Sep 18 '24 17:09 barneyjackson