Example Prometheus Nodejs

Prometheus monitoring example with Node.js
Alternatives To Example Prometheus Nodejs
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
18 hours ago302gpl-3.0C
Real-time performance monitoring, done right! https://www.netdata.cloud
Grafana54,524252417 hours ago3,297September 23, 20223,288agpl-3.0TypeScript
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
Prometheus47,27059417 hours ago703September 12, 2022853apache-2.0Go
The Prometheus monitoring system and time series database.
Thanos11,5526719 hours ago451August 26, 2022343apache-2.0Go
Highly available Prometheus setup with long term storage capabilities. A CNCF Incubating project.
Victoriametrics8,194418 hours ago174September 08, 2022631apache-2.0Go
VictoriaMetrics: fast, cost-effective monitoring solution and time series database
Prometheus Operator7,86725917 hours ago295September 20, 2022274apache-2.0Go
Prometheus Operator creates/configures/manages Prometheus clusters atop Kubernetes
Statping6,55622 months ago138December 18, 202054gpl-3.0Vue
Status Page for monitoring your websites and applications with beautiful graphs, analytics, and plugins. Run on any type of environment.
Alertmanager5,564662402 days ago149April 05, 2022429apache-2.0Go
Prometheus Alertmanager
23 days ago5mit
Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager
Cortex5,0249617 hours ago325July 15, 2022189apache-2.0Go
A horizontally scalable, highly available, multi-tenant, long term Prometheus.
Alternatives To Example Prometheus Nodejs
Select To Compare

Alternative Project Comparisons

Example Prometheus Monitoring


Setup monitoring with Prometheus and Grafana.


  1. Run sample server: npm install and node server
  2. Run Prometheus: see below
  3. Visit your running Prometheus and run queries
  4. Run Grafana: see below
  5. Add Prometheus data source (Url: http://localhost:9090, Access: direct)
  6. Import grafana-dashboard.json dashboard
  7. Create your own dashboard from the Prometheus queries


  • Docker


Modify: /prometheus-data/prometheus.yml, replace with your own host machine's IP.
Host machine IP address: ifconfig | grep 'inet 192'| awk '{ print $2}'

docker run -p 9090:9090 -v "$(pwd)/prometheus-data":/prometheus-data prom/prometheus -config.file=/prometheus-data/prometheus.yml

Open Prometheus: http://localhost:9090

Example Queries


Error rate

Range[0,1]: number of 5xx requests / total number of requests

sum(increase(http_request_duration_ms_count{code=~"^5..$"}[1m])) /  sum(increase(http_request_duration_ms_count[1m]))
Request Per Minute
sum(rate(http_request_duration_ms_count[1m])) by (service, route, method, code)  * 60

Response Time


Apdex score approximation:
100ms target and 300ms tolerated response time

  sum(rate(http_request_duration_ms_bucket{le="100"}[1m])) by (service)
  sum(rate(http_request_duration_ms_bucket{le="300"}[1m])) by (service)
) / 2 / sum(rate(http_request_duration_ms_count[1m])) by (service)

Note that we divide the sum of both buckets. The reason is that the histogram buckets are cumulative. The le="100" bucket is also contained in the le="300" bucket; dividing it by 2 corrects for that. - Prometheus docs

95th Response Time
histogram_quantile(0.95, sum(rate(http_request_duration_ms_bucket[1m])) by (le, service, route, method))
Median Response Time:
histogram_quantile(0.5, sum(rate(http_request_duration_ms_bucket[1m])) by (le, service, route, method))
Average Response Time
avg(rate(http_request_duration_ms_sum[1m]) / rate(http_request_duration_ms_count[1m])) by (service, route, method, code)

Memory Usage

Average Memory Usage

In Megabyte.

avg(nodejs_external_memory_bytes / 1024 / 1024) by (service)

Reload config

Necessary when you modified prometheus-data.

curl -X POST http://localhost:9090/-/reload

Prometheus Data

avg(rate(http_request_duration_ms_sum[1m]) / rate(http_request_duration_ms_count[1m])) by (service, route, method, code)

Prometheus - Data

Prometheus Alerts

States of active alerts: pending, firing

Prometheus - Alert Pending Prometheus - Alert Firing



docker run -i -p 3000:3000 grafana/grafana

Open Grafana: http://localhost:3000

Username: admin
Password: admin

Setting datasource

Create a Grafana datasource with this settings:

Or use this curl request:

curl 'http://admin:[email protected]:3000/api/datasources' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"name":"DS_PROMETHEUS","type":"prometheus","url":"http://localhost:9090","access":"direct","jsonData":{"keepCookies":[]},"secureJsonFields":{}}' --compressed

Setting dashboard

Grafana Dashboard to import: /grafana-dashboard.json

Or use this curl request:

curl 'http://admin:[email protected]:3000/api/dashboards/import' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '%{copy and paste grafana-dashboard.json}' --compressed

Grafana Dashboard

Grafana - Response Time Grafana - Throughput


This example is sponsored by Trace by RisingStack.

Popular Monitoring Projects
Popular Prometheus Projects
Popular Operations Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.