Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bmatei/apollo-prometheus-exporter

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bmatei/apollo-prometheus-exporter

Plugin for Apollo Server to export metrics in Prometheus format

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Apollo Prometheus Exporter

GitHub Workflow Status npm

Plugin for Apollo Server to export metrics in Prometheus format.

It uses prom-client under the hood the export the metrics.

Since Apollo Server released a new major version, a new version (v2.x.y) of the exporter has been launched. Apollo Server v2 is still supported in v1.x.y. The two versions will be features-matched as much as possible.

Metrics

NameDescriptionType
apollo_server_startingThe last timestamp when Apollo Server was starting.Gauge
apollo_server_closingThe last timestamp when Apollo Server was closing.Gauge
apollo_query_startedThe amount of received queries.Counter
apollo_query_failedThe amount of queries that failed.Counter
apollo_query_parse_startedThe amount of queries for which parsing has started.Counter
apollo_query_parse_failedThe amount of queries for which parsing has failed.Counter
apollo_query_validation_startedThe amount of queries for which validation has started.Counter
apollo_query_validation_failedThe amount of queries for which validation has failed.Counter
apollo_query_resolvedThe amount of queries which could be resolved.Counter
apollo_query_execution_startedThe amount of queries for which execution has started.Counter
apollo_query_execution_failedThe amount of queries for which execution has failed.Counter
apollo_query_durationThe total duration of a query.Histogram
apollo_query_field_resolution_durationThe total duration for resolving fields.Histogram

For default metrics, please refer to prom-client default metrics.

Usage

  1. Install prom-client and @bmatei/apollo-prometheus-exporter

    npm install prom-client @bmatei/apollo-prometheus-exporter
    
  2. Create an instance of the plugin

    const app = express();
    
    const prometheusExporterPlugin = createPrometheusExporterPlugin({ app });
    
  3. Add the plugin to ApolloServer

    const server = new ApolloServer({
      plugins: [prometheusExporterPlugin]
    });
    

For a complete working example, please have a look over the example project in this repository.

Options

NameDescriptionTypeDefault Value
appExpress instance. For the moment it is used for defining the metrics endpoint. It is mandatory unless metricsEndpoint is set to false.Expressundefined
defaultLabelsAn object containing default labels to be sent with each metric.Object{}
defaultMetricsFlag to enable/disable the default metrics registered by prom-client.Booleantrue
defaultMetricsOptionsConfiguration object for the default metrics.DefaultMetricsCollectorConfiguration{}
durationHistogramBucketsA list of durations that should be used by histograms.number[][0.001, 0.005, 0.015, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 1, 5, 10]
hostnameLabelFlag to enable/disable hostname label.Booleantrue
hostnameLabelNameThe name of the hostname label.Stringhostname
metricsEndpointFlag to enable/disable the metrics endpoint. If you disable this, you can use the registerPrometheusMetricsEndpoint method to enable the metrics endpoint.Booleantrue
metricsEndpointPathHTTP path where the metrics will be published.String"/metrics"
registerPrometheus client registry to be used by Apollo Metrics. By default, it is also used by the default metrics.Registryregister
skipMetricsA key-value map that controls if a metric is enabled or disabled.SkipMetricsMap{}

Thanks

Keywords

FAQs

Package last updated on 22 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc