节点输出器
月球导出器 显示度量衡 节点后置。 。 。 .
可用计量
出口商提供以下衡量标准.
pg. 计算机计量
| 计量名称 | 说明 | 标签 | 自兹 |
|---|---|---|---|
| pg 客户端 错误 总计 | 数据库连接错误的总数 |
| 1.0.0 (单位:千美元) |
| pg 客户端 断开连接 总计 | 断开连接的总数 |
| 1.0.0 (单位:千美元) |
pg. Pool计量器
| 计量名称 | 说明 | 标签 | 自兹 |
|---|---|---|---|
| pg pool 连接 创建 总计 | 创建连接的总数 |
| 1.0.0 (单位:千美元) |
| 池大小 | 连接池的当前大小,包括活动成员和闲置成员 |
| 1.0.0 (单位:千美元) |
| pg pool 活动 连接 | 活动连接的总数 |
| 1.0.0 (单位:千美元) |
| pg pool errors 总计 | 数据库连接错误的总数 |
| 1.0.0 (单位:千美元) |
| pg pool 连接 removed total | 已删除连接的总数 |
| 1.0.0 (单位:千美元) |
示例输出
这里举出一个实例,以提供的度量符的正方形格式输出.
# HELP pg_client_errors_total The total number of connection errors with a database.
# TYPE pg_client_errors_total counter
pg_client_errors_total{host="localhost:5432",database="node_postgres_test1"} 1
# HELP pg_client_disconnects_total The total number of disconnected connections.
# TYPE pg_client_disconnects_total counter
pg_client_disconnects_total{host="localhost:5432",database="node_postgres_test1"} 1
# HELP pg_pool_connections_created_total The total number of created connections.
# TYPE pg_pool_connections_created_total counter
pg_pool_connections_created_total{host="localhost:5432",database="node_postgres_test1"} 19
# HELP pg_pool_size The current size of the connection pool, including active and idle members.
# TYPE pg_pool_size gauge
pg_pool_size{host="localhost:5432",database="node_postgres_test1"} 10
# HELP pg_pool_max The maximum size of the connection pool.
# TYPE pg_pool_max gauge
pg_pool_max{host="localhost:5432",database="node_postgres_test1"} 10
# HELP pg_pool_active_connections The total number of active connections.
# TYPE pg_pool_active_connections gauge
pg_pool_active_connections{host="localhost:5432",database="node_postgres_test1"} 10
# HELP pg_pool_waiting_connections The total number of waiting connections.
# TYPE pg_pool_waiting_connections gauge
pg_pool_waiting_connections{host="localhost:5432",database="node_postgres_test1"} 1
# HELP pg_pool_idle_connections The total number of idle connections.
# TYPE pg_pool_idle_connections gauge
pg_pool_idle_connections{host="localhost:5432",database="node_postgres_test1"} 0
# HELP pg_pool_errors_total The total number of connection errors with a database.
# TYPE pg_pool_errors_total counter
pg_pool_errors_total{host="localhost:5432",database="node_postgres_test1"} 1
# HELP pg_pool_connections_removed_total The total number of removed connections.
# TYPE pg_pool_connections_removed_total counter
pg_pool_connections_removed_total{host="localhost:5432",database="node_postgres_test1"} 9
使用量
依赖性
在您的工程中添加以下依赖性以下载软件包 无。 。 。 .
npm i @christiangalsterer/node-postgres-prometheus-exporter
类型脚本
以下例子说明如何利用出口者监测节点.
import { Client, Pool } from 'pg'
import { Registry, collectDefaultMetrics } from 'prom-client'
import { monitorPgClient, monitorPgPool } from '@christiangalsterer/node-postgres-prometheus-exporter'
...
// set up a pg.Client
const client = new Client()
// set up a pg.Pool
const pool = new Pool()
// set up the prometheus client
const register = new Registry();
collectDefaultMetrics({ register })
// monitor the pg.Client
monitorPgClient(client, register)
// monitor the pg.Pool
monitorPgPool(pool, register)
...
// connect to PostgreSQL *after* calling monitorPgClient() / monitorPgPool()
await client.connect()
await pool.connect()
Java 脚本
以下例子说明如何利用出口者监测节点.
const pg = require('pg')
const promClient = require( 'prom-client');
const postgresExporter = require('@christiangalsterer/node-postgres-prometheus-exporter')
// set up a pg.Client
const client = new pg.Client()
// set up a pg.Pool
const pool = new pg.Pool()
// set up the prometheus client
const collectDefaultMetrics = promClient.collectDefaultMetrics;
const Registry = promClient.Registry;
const register = new Registry();
collectDefaultMetrics({ register });
// monitor the pg.Client
postgresExporter.monitorPgClient(client, register)
// monitor the pg.Pool
postgresExporter.monitorPgPool(pool, register)
// connect to Postgres *after* calling monitorPgClient() / monitorPgPool()
await client.connect()
await pool.connect()
配置
出口商可以通过类型可选参数指定的属性配置 PgClient 输出选项 财务报告和审定财务报表 PgPool 输出选项 页:1.
PgClient 输出选项
| 属性 | 说明 | 示例 | 自兹 |
|---|---|---|---|
| 默认标签 | 默认标签添加到每个参数中 . | {'foo':'bar','alice': 3} (中文(简体) ) | 1.0.0 (单位:千美元) |
PgPool 输出选项
| 属性 | 说明 | 示例 | 自兹 |
|---|---|---|---|
| 默认标签 | 默认标签添加到每个参数中 . | {'foo':'bar','alice': 3} (中文(简体) ) | 1.0.0 (单位:千美元) |
格拉法纳板
Grafana 的示例 这里 显示出口商提供的衡量标准.
以下是节点后置客户端计量的示例:

这里有一个节点点集合度量法的例子:

更改日志
项目的更改可见于 更改日志。 。 。 .
兼容性
下表列出了出口商版本与不同的节点邮递版本和舞会客户端版本的相容性.
| 导出版本 | 节点张贴版本 | 舞会客户端版本 |
|---|---|---|
| ^ 1. 0 | ^ 8.11.0 (韩语) | ^15.0 |
捐款
发言是十分受欢迎的。 如欲为该项目捐款,请遵循本报告所述步骤 捐款准则。 。 。 .
使用导出者的项目
如果您想要支持此项目, 请在您使用此导出时在您的项目和/ 或公司中添加链接 .
相关项目
如果您在寻找一种方法来监视您的节点驱动程序, 请查看 https://github.com/christiangalster/mongodb-driver-prometheus-exporter (中文(简体) )。 。 。 .
如果你正在寻找一种方法 监视KafkaJs的节点 https://github.com/christiangalster/kafkajs-prometheus-exporter (中文(简体) )。 。 。 .