Data configurationGrafana integrationsIntegrations referenceApollo Server integration

Apollo Server integration for Grafana Cloud

Apollo Server is an open-source, spec-compliant GraphQL server that’s compatible with any GraphQL client, including Apollo Client. It provides a way to build a production-ready, self-documenting GraphQL API. This integration enables the agent to send Apollo Server metrics to Grafana Cloud along with a useful default dashboard for visualization.

Before you begin

This integration monitors an Apollo Server app that exposes metrics through Apollo Prometheus Exporter.

In order to expose metrics to the agent you must instrument your Apollo server:

  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 });
 
  1. Add the plugin to ApolloServer
const server = new ApolloServer({
  plugins: [prometheusExporterPlugin]
});

For further instructions and a full list of configuration options, refer to the Apollo Prometheus exporter guide.

Install Apollo Server integration for Grafana Cloud

  1. In your Grafana instance, click Integrations and Connections (lightning bolt icon), then click on the Apollo Server tile to install the integration.
  2. Once the integration is installed, follow the steps on the Configuration Details page to configure Grafana Agent to automatically scrape and send Apollo Server metrics to your Grafana Cloud instance.

Post-install configuration

In the agent configuration file, the agent must be pointed to the Apollo Server app, such as apollo-server:4000 in the example below, that exposes the /metrics endpoint.

metrics:
  wal_directory: /tmp/wal
  configs:
    - name: integrations
      scrape_configs:
        - job_name: apollo-server-integration
          static_configs:
            - targets: ['apollo-server:4000']
      remote_write:
        - url: http://cortex:9009/api/prom/push

Dashboards

The Apollo Server integration for Grafana Cloud installs one prebuilt dashboard that allows you to visualize your Apollo Server metrics, such as CPU usage, requests per second, response latency, and more.

Apollo Server Overview dashboard

This dashboard gives a general overview of Apollo Server metrics exposed by the agent. The dashboard can show aggregated statistics along with individual statistics based on the selected job, instance, and hostname.

Apollo Server overview dashboard example

Metrics captured by Apollo Server for Grafana Cloud

A sample of the metrics being collected can be found here in the following .txt file: Apollo Server metrics

The metrics collected and utilized on the dashboard includes:

  • Apdex Score
  • Requests Per Second
  • Requests Count
  • Requests Error Rate
  • Errors Per Second
  • Response Latency
  • Node.js Restarts
  • Apollo Server Restarts
  • Apollo Server Version
  • Top 10 most requested operations
  • Top 10 operations that errored
  • Top 10 slowest operations
  • Top 10 fields with the slowest resolutions
  • Process CPU Usage
  • Process Memory Usage

Cost

By connecting your Apollo Server integration to Grafana Cloud you might incur charges. For more information, use the following links:

For an increase in the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.