Apollo Prometheus Plugin

Install
npm install @thecodenebula/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 '@thecodenebula/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
| metric | type | labels | |---------------------- |----------- |--------------------------------------- | | errorsencountered | Counter | operationNameoperation
error | | requestsresolved | Counter | operationName
operation | | attributesrequested | Counter | fieldName
parentType | | resolvertime | Histogram | fieldName
parentType
returnType | | totalrequesttime | Histogram | operationName
operation |