Get started with Grafana integrationsCurrently available IntegrationsNode.js integration

Node.js integration for Grafana Cloud

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that executes JavaScript code outside a web browser.

The Node.js integration for Grafana Cloud enables you to monitor your Node.js application with the default metrics exposed through prom-client. This integration allows the Grafana agent to send metrics to Grafana Cloud and provides a prebuilt dashboard to help you monitor and visualize them.

Before you begin

In order to send metrics to Grafana Cloud the prom-client must be installed on your Node.js app with the default metrics enabled. Once prom-client is installed, the metrics can be exposed under /metrics endpoint.

See the following configuration example to configure your application:

import express from 'express';
import { collectDefaultMetrics, register } from 'prom-client';

collectDefaultMetrics();

const app = express();

app.get('/metrics', async (_req, res) => {
  try {
    res.set('Content-Type', register.contentType);
    res.end(await register.metrics());
  } catch (err) {
    res.status(500).end(err);
  }
});

app.listen(4001, '0.0.0.0');

After the application is configured, you can proceed with installing the integration and configuring the Grafana agent.

Install Node.js integration for Grafana Cloud

  1. In your Grafana instance, click Integrations and Connections (lightning bolt icon), then search or navigate to the Node.js tile.

  2. Click the Node.js tile and click Install Integration.

  3. Once the integration is installed, follow the steps on the Configuration Details page to setup Grafana Agent to automatically scrape and send your Node.js app metrics to your Grafana Cloud Instance.

Post-install configuration for the Node.js integration

In the agent configuration file, the agent must be pointed to the Node.js app, such as nodejs-app:4001 in the example below, that exposes the /metrics endpoint.

metrics:
  wal_directory: /tmp/wal
  global:
    scrape_interval: 15s
  configs:
    - name: integrations
      scrape_configs:
        - job_name: integrations/nodejs
          static_configs:
            - targets: ['nodejs-app:4001']
      remote_write:
        - url: http://cortex:9009/api/prom/push

Dashboards

After you have successfully configured the Node.js integration, a prebuilt dashboard is installed in your Grafana Cloud instance to help you monitor your Node.js metrics.

This dashboard provides a general overview of the Node.js metrics exposed by Grafana Agent. The dashboard surfaces process metrics including CPU usage, event loop latency, memory usage, and active handlers and requests. Along with GC metrics such as duration rate, count, and heap space used.

Node.js overview dashboard

Metrics captured by Node.js integration for Grafana Cloud

The Grafana agent configuration provided by this integration will scrape all metrics exposed by the prom-client lib for Node.js.

To see the list of metrics scraped by this integration, refer to the Node.js metrics file

Cost

By connecting your Node.js application 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.