<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Node.js Exporter on Grafana Labs</title><link>https://grafana.com/oss/prometheus/exporters/nodejs-exporter/</link><description>Recent content in Node.js Exporter on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/oss/prometheus/exporters/nodejs-exporter/index.xml" rel="self" type="application/rss+xml"/><item><title>Alerting rules</title><link>https://grafana.com</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://grafana.com</guid><description>&lt;p>This quickstart includes the following alerting rules:&lt;/p>
&lt;ul>
&lt;li>&lt;code>NodejsDown&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Node.js &lt;code>job&lt;/code> on &lt;code>instance&lt;/code> is not up.&lt;/p>
&lt;a class="btn btn--primary br-5 mb-1" href="assets/alerting_rules.yaml" rel="noopener noreferrer">Download the following alerting rules YAML file&lt;/a>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">YAML&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-yaml">groups:
- name: NodejsAlerts
rules:
- alert: NodejsDown
expr: process_start_time_seconds != 1
for: 5m
labels:
severity: critical
annotations:
description: &amp;#39;Node.js {{$labels.job}} on {{$labels.instance}} is not up.&amp;#39;
summary: Node.js not up&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>This alerting rule YAML file was generated using the prom-client for Node.js &lt;a href="https://github.com/grafana/jsonnet-libs/tree/master/nodejs-mixin" target="_blank" rel="noopener noreferrer">mixin&lt;/a>.&lt;/p></description></item><item><title>Cloud integration</title><link>https://grafana.com</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://grafana.com</guid><description>
&lt;div class="bg-solitude p-1 mb-1" style="">
&lt;p>Grafana Cloud comes with an ever-expanding set of integrations to quickly get an observability stack up and running in minutes. The Node.js app Integration, built-in to the Grafana Cloud Agent, exposes and scrapes essential Node.js app metrics and pushes them to Grafana Cloud. The agent will scrape metrics using an embedded prom-client for Node.js, and Grafana Cloud will automatically provision tailored Grafana dashboards and alerts for visualizing and acting on this data.&lt;/p>
&lt;div>
&lt;a class="btn btn--primary br-5 " href="/auth/sign-up/create-user?pg=oss-prom-nodejs-exporter&amp;amp;plcmt=body-txt-overview" rel="noopener noreferrer">Sign up for a free account to get started&lt;/a>
&lt;/div>
&lt;/div>
&lt;p>To learn more, check out the &lt;a href="/docs/grafana-cloud/integrations/">Grafana Cloud docs&lt;/a>.&lt;/p>
&lt;h4 id="how-it-works">How it works&lt;/h4>
&lt;p>Configuring, installing, connecting, and maintaining Prometheus monitoring components typically involves significant domain knowledge. It can take quite a while to go from setup to dashboard and alerts. As the creators of Grafana - and core contributors to Prometheus and Cortex - we build simple integrations to abstract some of this work away in order to quickly get started. How it works:&lt;/p>
&lt;ol>
&lt;li>Sign up (or log in) for a &lt;a href="/auth/sign-up/create-user?pg=oss-prom-nodejs-exporter&amp;amp;plcmt=body-txt-overview">free Grafana Cloud account&lt;/a>.&lt;/li>
&lt;li>Select the target you’d like to observe (an ever-expanding catalogue).&lt;/li>
&lt;li>Run a one-line command to install the Grafana Agent. The agent embeds and preconfigures Exporters to expose default metrics, and pushes them to the Grafana Cloud metrics backend.&lt;/li>
&lt;li>Voila! You’ll see tailored Grafana dashboards and will benefit from sane alerting defaults.&lt;/li>
&lt;/ol>
&lt;p>Looking for a different Exporter or integration? Check out our &lt;a href="/docs/grafana-cloud/integrations/">growing library of integrations for popular components&lt;/a> like MySQL, Postgres, Redis, Memcached and more.&lt;/p></description></item><item><title>Dashboards</title><link>https://grafana.com</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://grafana.com</guid><description>&lt;h3 id="nodejs-overview-dashboard">Node.js Overview Dashboard&lt;/h3>
&lt;p>&lt;img
class="lazyload d-inline-block"
src="/api/dashboards/14058/images/10052/image"
alt="Node.js Overview Dashboard"/>&lt;/p>
&lt;p>This dashboard includes panels for the following metrics:&lt;/p>
&lt;ul>
&lt;li>Node.js Version&lt;/li>
&lt;li>Node.js Restarts&lt;/li>
&lt;li>CPU Usage&lt;/li>
&lt;li>CPU Time Spent&lt;/li>
&lt;li>Memory Usage&lt;/li>
&lt;li>Active Handlers and Requests&lt;/li>
&lt;li>Event Loop Latency&lt;/li>
&lt;li>GC Duration Rate&lt;/li>
&lt;li>GC Duration&lt;/li>
&lt;li>Heap Memory Usage&lt;/li>
&lt;li>GC Rate&lt;/li>
&lt;li>GC Count&lt;/li>
&lt;li>Heap Space Used&lt;/li>
&lt;/ul>
&lt;p>You can import the dashboard directly using the following dashboard ID: &lt;strong>&lt;code>14058&lt;/code>&lt;/strong>.&lt;/p>
&lt;p>You can fetch the dashboard JSON &lt;a href="/api/dashboards/14058/revisions/1/download">&lt;strong>here&lt;/strong>&lt;/a>.&lt;/p>
&lt;p>This dashboard was generated using the prom-client for Node.js &lt;a href="https://github.com/grafana/jsonnet-libs/tree/master/nodejs-mixin" target="_blank" rel="noopener noreferrer">mixin&lt;/a>.&lt;/p></description></item><item><title>Install</title><link>https://grafana.com</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://grafana.com</guid><description>&lt;h2 id="prom-client-for-nodejs-quickstart">prom-client for Node.js Quickstart&lt;/h2>
&lt;p>In this guide you&amp;rsquo;ll learn how to set up and configure prom-client for Node.js to collect Node.js metrics like event loop lag and active handles and expose them as Prometheus-style metrics. You&amp;rsquo;ll then configure &lt;a href="https://prometheus.io/" target="_blank" rel="noopener noreferrer">Prometheus&lt;/a> to scrape Node.js metrics and optionally ship them to Grafana Cloud. Finally, you&amp;rsquo;ll set up a preconfigured and curated set of Grafana &lt;a href="/grafana/dashboards">dashboards&lt;/a>, and &lt;a href="https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/" target="_blank" rel="noopener noreferrer">alerting rules&lt;/a>. At the end of this guide you&amp;rsquo;ll have dashboards that you can use to visualize your Node.js metrics, and a set of preconfigured alerts.&lt;/p>
&lt;p>If you&amp;rsquo;re using &lt;a href="/products/cloud/">Grafana Cloud&lt;/a>, the &lt;a href="/docs/grafana-cloud/integrations/integration-nodejs/">Node.js&lt;/a> Integration can help you get up and running quickly. The Node.js Integration embeds prom-client for Node.js into the &lt;a href="https://github.com/grafana/agent" target="_blank" rel="noopener noreferrer">Grafana Cloud Agent&lt;/a> and automatically provisions alerting rules and dashboards, so you don&amp;rsquo;t have to run through the steps in this guide. To learn how to set up prom-client for Node.js using the Node.js Integration, please see &lt;a href="/docs/grafana-cloud/integrations/integration-nodejs/">Node.js Integration&lt;/a> from the Grafana Cloud docs.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;p>Before you get started, you should have the following available to you:&lt;/p>
&lt;ul>
&lt;li>Node.js installed on your machine. To learn more, please see &lt;a href="https://nodejs.org/en/download/" target="_blank" rel="noopener noreferrer">Downloads&lt;/a> from the Node.js site.&lt;/li>
&lt;li>Prometheus running in your environment or directly on the machine. To learn how to install Prometheus, please see &lt;a href="https://prometheus.io/docs/prometheus/latest/installation/" target="_blank" rel="noopener noreferrer">Installation&lt;/a> from the Prometheus docs.&lt;/li>
&lt;li>Grafana running in your environment or directly on the machine. To learn how to install Grafana, please see &lt;a href="/docs/grafana/latest/installation/">Install Grafana&lt;/a> from the Grafana docs.&lt;/li>
&lt;li>(Optional) A Grafana Cloud account. Grafana Cloud hosts Grafana and a &lt;a href="/oss/mimir/">Mimir&lt;/a>-based Prometheus metrics endpoint. You will still need to scrape metrics, using either Prometheus installed in your environment, or the &lt;a href="https://github.com/grafana/agent" target="_blank" rel="noopener noreferrer">Grafana Cloud Agent&lt;/a>. To learn more about Grafana Cloud, please see &lt;a href="/products/cloud/">Grafana Cloud&lt;/a>.&lt;/li>
&lt;/ul>
&lt;h2 id="step-1-setting-up-prom-client-for-nodejs">Step 1: Setting up prom-client for Node.js&lt;/h2>
&lt;p>In this step you&amp;rsquo;ll set up prom-client for Node.js to collect and expose Node.js metrics in Prometheus format. This guide uses an Ubuntu 20.04 system with Node.js version &lt;code>15.11.0&lt;/code>. Steps may vary slightly depending on your operating system and Node.js version.&lt;/p>
&lt;p>This guide will demonstrate setup steps for a new Node.js app. To instrument an existing Node.js app, please see the &lt;code>prom-client&lt;/code> &lt;a href="https://github.com/siimon/prom-client" target="_blank" rel="noopener noreferrer">GitHub repository&lt;/a>.&lt;/p>
&lt;p>To begin, log in to your machine and create a new app directory called &lt;code>app&lt;/code>. Navigate into this directory:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">mkdir app
cd&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>Initialize the Node project using &lt;code>npm init&lt;/code>:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">npm init&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>Use the defaults for everything, except for the following prompt:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">entry point: (index.js)&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>For this prompt, enter &lt;code>app.js&lt;/code> then hit &lt;code>ENTER&lt;/code>.&lt;/p>
&lt;p>Next, install &lt;code>express&lt;/code> and &lt;code>prom-client&lt;/code> using &lt;code>npm&lt;/code>:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">npm install express prom-client --save&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>Finally, create the minimal app using your favorite text editor. Open a file called &lt;code>app.js&lt;/code> and paste in the following:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">import express from &amp;#39;express&amp;#39;;
import { collectDefaultMetrics, register } from &amp;#39;prom-client&amp;#39;;
collectDefaultMetrics();
const app = express();
app.get(&amp;#39;/metrics&amp;#39;, async (_req, res) =&amp;gt; {
try {
res.set(&amp;#39;Content-Type&amp;#39;, register.contentType);
res.end(await register.metrics());
} catch (err) {
res.status(500).end(err);
}
});
app.listen(4001, &amp;#39;0.0.0.0&amp;#39;);&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>This barebones app collects a standard set of Node.js metrics and exposes them in Prometheus format at the &lt;code>/metrics&lt;/code> endpoint. It listens for requests on port &lt;code>4001&lt;/code> at &lt;code>localhost&lt;/code>.&lt;/p>
&lt;p>When you&amp;rsquo;re done, save and close the file.&lt;/p>
&lt;p>Finally, run the app using Node:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">node app.js&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>You won&amp;rsquo;t see any output, but your shell should hang. In another session, simulate a Prometheus scrape using &lt;code>curl&lt;/code>:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">curl localhost:4001/metrics&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">. . .
# HELP nodejs_gc_duration_seconds Garbage collection duration by kind, one of major, minor, incremental or weakcb.
# TYPE nodejs_gc_duration_seconds histogram
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.001&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.01&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.1&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;1&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;2&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;5&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;&amp;#43;Inf&amp;#34;,kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_sum{kind=&amp;#34;incremental&amp;#34;} 0.007554849
nodejs_gc_duration_seconds_count{kind=&amp;#34;incremental&amp;#34;} 4
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.001&amp;#34;,kind=&amp;#34;major&amp;#34;} 0
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.01&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;0.1&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;1&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;2&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;5&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_bucket{le=&amp;#34;&amp;#43;Inf&amp;#34;,kind=&amp;#34;major&amp;#34;} 2
nodejs_gc_duration_seconds_sum{kind=&amp;#34;major&amp;#34;} 0.007220236999999999
nodejs_gc_duration_seconds_count{kind=&amp;#34;major&amp;#34;} 2&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>If you see the above output, you successfully installed prom-client into your Node.js app. You&amp;rsquo;re ready to begin scraping Node.js metrics using Prometheus.&lt;/p>
&lt;p>Beyond &lt;code>collectDefaultMetrics&lt;/code>, &lt;code>prom-client&lt;/code> can collect custom Node.js metrics and allows you to configure metric labels. To learn more about these features, please see the &lt;a href="https://github.com/siimon/prom-client" target="_blank" rel="noopener noreferrer">prom-client for Node.js GitHub repository&lt;/a>.&lt;/p>
&lt;h2 id="step-2-scraping-prom-client-metrics-using-prometheus">Step 2: Scraping prom-client metrics using Prometheus&lt;/h2>
&lt;p>Now that prom-client is up and running on your machine, you can configure a Prometheus scrape job to collect and store Node.js metrics.&lt;/p>
&lt;p>Add the following scrape job config to the &lt;code>scrape_configs&lt;/code> section of your &lt;code>prometheus.yml&lt;/code> configuration file:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">- job_name: nodejs
static_configs:
- targets: [&amp;#39;localhost:4001&amp;#39;]&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>Replace &lt;code>localhost&lt;/code> with the IP address of the machine running Node.js. If you&amp;rsquo;re running Prometheus on the same machine, this will be &lt;code>localhost&lt;/code>. To learn more about configuring Prometheus, please see &lt;a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/" target="_blank" rel="noopener noreferrer">Configuration&lt;/a> from the Prometheus docs.&lt;/p>
&lt;p>If you don&amp;rsquo;t have a &lt;code>prometheus.yml&lt;/code> configuration file, create a simple one using your favorite text editor. Open your preferred text editor and paste in the following Prometheus configuration:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">global:
scrape_interval: 15s
scrape_configs:
- job_name: nodejs
static_configs:
- targets: [&amp;#39;localhost:4001&amp;#39;]&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>This configuration tells Prometheus to scrape all jobs every 15 seconds. The only configured scrape job is called &lt;code>nodejs&lt;/code> and defines a &lt;code>localhost:4001&lt;/code> target. By default, Prometheus will scrape the &lt;code>/metrics&lt;/code> endpoint using HTTP.&lt;/p>
&lt;p>Save and close the file. You can then run Prometheus with the file using the following command:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">./prometheus --config.file=./prometheus.yml&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;h3 id="shipping-metrics-to-grafana-cloud">Shipping metrics to Grafana Cloud&lt;/h3>
&lt;p>To ship Node.js metrics to Grafana Cloud from Prometheus, configure the &lt;code>remote_write&lt;/code> parameter in your &lt;code>prometheus.yml&lt;/code> configuration file. To learn more, please see &lt;a href="/docs/grafana-cloud/metrics/prometheus/">Metrics — Prometheus&lt;/a> from the Grafana Cloud docs. To learn more about the &lt;code>remote_write&lt;/code> parameter, please see &lt;a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write" target="_blank" rel="noopener noreferrer">&lt;code>remote_write&lt;/code>&lt;/a> from the Prometheus docs.&lt;/p>
&lt;h2 id="step-3-configuring-dashboards">Step 3: Configuring dashboards&lt;/h2>
&lt;p>This quickstart includes one dashboard:&lt;/p>
&lt;ul>
&lt;li>Node.js Overview&lt;/li>
&lt;/ul>
&lt;p>To learn how to import this dashboards into Grafana, please see &lt;a href="/docs/grafana/latest/dashboards/export-import/#importing-a-dashboard">Importing a dashboard&lt;/a> from the Grafana docs.&lt;/p>
&lt;p>You can fetch the dashboards &lt;a href="?tab=dashboards">here&lt;/a>.&lt;/p>
&lt;h2 id="step-4-configuring-alerts">Step 4: Configuring alerts&lt;/h2>
&lt;p>With Prometheus alerting rules, you can define alerts that fire when PromQL expressions breach some threshold or satisfy specified conditions over a period of time. For example, you can define a &lt;code>HighRequestLatency&lt;/code> alert that fires when a request latency metric is greater than some threshold over a period of time. As soon as the alerting condition is triggered, the alert moves into &lt;code>Pending&lt;/code> state. After satisfying the condition for the period of time defined by the &lt;code>for&lt;/code> parameter, the alert moves into &lt;code>Firing&lt;/code> state. You can configure routing and notifications for firing alerts using a tool like &lt;a href="https://prometheus.io/docs/alerting/latest/alertmanager/" target="_blank" rel="noopener noreferrer">Alertmanager&lt;/a>. Alertmanager is also built-in to Grafana Cloud.&lt;/p>
&lt;p>You can fetch the alerting rule YAML file &lt;a href="?tab=alerting-rules">here&lt;/a>.&lt;/p>
&lt;h3 id="load-alerting-rules-into-prometheus">Load alerting rules into Prometheus&lt;/h3>
&lt;p>To load alerting rules into Prometheus, add the following to your &lt;code>prometheus.yml&lt;/code> configuration file:&lt;/p>
&lt;div class="code-snippet code-snippet__mini">&lt;div class="lang-toolbar__mini">
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;/div>&lt;div class="code-snippet code-snippet__border">
&lt;pre data-expanded="false">&lt;code class="language-none">rule_files:
- &amp;#34;nodejs-rules.yml&amp;#34;&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;p>Be sure to replace &lt;code>nodejs-rules.yml&lt;/code> with the path to your Node.js app alerting rules YAML file.&lt;/p>
&lt;h3 id="load-alerting-rules-into-grafana-cloud">Load alerting rules into Grafana Cloud&lt;/h3>
&lt;p>To learn how to load alerting rules into Grafana Cloud, please see &lt;a href="/docs/grafana-cloud/alerts/alerts-rules/#prometheus-and-loki-rules-with-cortextool">Prometheus and Loki rules with cortextool&lt;/a>.&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>In this quickstart you installed and ran prom-client for Node.js on your Linux machine. You then configured Prometheus to scrape the database and Node.js app metrics exposed by prom-client for Node.js. You loaded recording rules and alerting rules into Prometheus, and finally imported Grafana dashboards to visualize your Node.js app metrics.&lt;/p>
&lt;p>If you&amp;rsquo;re using Grafana Cloud, you can skip all of the steps in this guide by installing the Node.js app integration with the Grafana Cloud Agent. This integration embeds a preconfigured prom-client for Node.js into the agent and automatically provisions Grafana dashboards and Prometheus alerting and recording rules, so you don&amp;rsquo;t have to import them manually. To learn how to set up the Node.js app integration, please see &lt;a href="/docs/grafana-cloud/integrations/">Grafana Cloud Integrations&lt;/a>.&lt;/p>
&lt;p>The dashboards, recording rules, and alerting rules were generated using the prom-client for Node.js Mixin. Mixins are reusable templates for dasboards, recording rules, and alerts curated and designed by subject matter experts. To learn more, please see the &lt;a href="https://github.com/grafana/jsonnet-libs/tree/master/nodejs-mixin" target="_blank" rel="noopener noreferrer">Node.js app Mixin&lt;/a> repository.&lt;/p></description></item></channel></rss>