3.0.0 • Published 1 year ago

@talabes/apollo-prometheus-plugin v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Apollo Prometheus Plugin

Fork with support for latest prom-client versions.

Install

npm install @talabes/apollo-prometheus-plugin

yarn add @talabes/apollo-prometheus-plugin

Usage

import { ApolloServer, gql } from 'apollo-server-express';
import { prometheusPlugin } from 'apollo-prometheus-plugin';
import { Registry } from 'prom-client';
import { prometheusPlugin } from '@talabes/apollo-prometheus-plugin';

const register = new Registry();

const app = express();

app.get('/metrics', (_, res) => res.send(register.metrics()));

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [prometheusPlugin(register, { enableNodeMetrics: true })],
});

server.applyMiddleware({ app, path: '/' });
app.listen({ port: 8080 }, () => {
  console.log('Listening');
});

Available metrics and labels

metrictypelabels
errors_encounteredCounteroperationName operation error
requests_resolvedCounteroperationNameoperation
attributes_requestedCounterfieldNameparentType
resolver_timeHistogramfieldNameparentTypereturnType
total_request_timeHistogramoperationNameoperation