prometheus-remote-write
v0.5.0
Published
Send samples to prometheus via remote_write from NodeJS
Downloads
19,295
Maintainers
Readme
Push timeseries to Prometheus via remote_write
Using remote_write facility (see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write) to send metrics to remote Prometheus from NodeJS app.
Pretty much anything from https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage should be supported, but tested only with Grafana Cloud, Grafana Mimir Prometheus, AWS AMP and VictoriaMetrics.
- AppOptics
- AWS Timestream
- AWS AMP - Managed Prometheus - Use function "createSignedFetcher" from NPM package aws-sigv4-fetch and provide it in options as customized fetcher.
- Azure Data Explorer
- Azure Event Hubs
- Chronix
- Cortex
- CrateDB
- Elasticsearch
- Gnocchi
- Google BigQuery
- Google Cloud Spanner
- Graphite
- InfluxDB
- Instana
- IRONdb
- Kafka
- M3DB
- New Relic
- OpenTSDB
- PostgreSQL/TimescaleDB
- QuasarDB
- SignalFx
- Splunk
- Sysdig Monitor
- TiKV
- Thanos
- VictoriaMetrics - docs
- Wavefront
(List copied from https://github.com/prometheus/docs/blob/main/content/docs/operating/integrations.md)
Usage:
import { pushTimeseries, pushMetrics } from "prometheus-remote-write";
// Just push some metrics metrics
await pushMetrics(
{
queue_depth_total: 100,
},
{
url: process.env.GRAFANA_PUSH_URL || "http://localhost:9201",
labels: { service: "queue-worker" },
}
);
// Follows remote_write payload format (see https://github.com/prometheus/prometheus/blob/main/prompb/types.proto)
await pushTimeseries(
{
labels: {
// Name should conform to https://prometheus.io/docs/practices/naming/
__name__: "queue_depth_total",
instance: "dev.example.com",
service: "SQS",
},
samples: [
{
value: 150,
timestamp: Date.now(),
},
],
},
config
);
// Full config - only url is required
const config = {
// Remote url
url: "http://localhost:9201",
// Auth settings
auth: {
username: "...",
password: "...",
},
// Optional prometheus protocol descripton .proto/.json
proto: undefined,
// Override default console.name(...log) used
console: undefined,
// Be verbose
verbose: false,
timing: false,
// Override used node-fetch
fetch: undefined,
// Additional labels to apply to each timeseries, i.e. [{ service: "SQS" }]
labels: undefined,
// Additional HTTP headers to send with each request
headers: undefined
};
Links
- https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write
- https://grafana.com/docs/grafana-cloud/metrics-prometheus/
- https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/install-configure-remote-write/set-your-prometheus-remote-write-integration/
- https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage