Skip to content

CoinIndexAgency/prometheus-remote-write

 
 

Repository files navigation

Push timeseries to Prometheus via remote_write

NPM version

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.com:

(List copied from https://github.com/prometheus/docs/blob/main/content/docs/operating/integrations.md)

Usage:

import pushTimeseries from "prometheus-remote-write";

const config = {
  // Remote url
  url: "http://localhost:9201",
  // Auth settings
  auth: {
    username: "...",
    password: "...",
  },
  // Optional prometheus protocol descripton .proto/.json
  proto: undefined,
  // Logging & debugging, disabled by default
  console: undefined,
  verbose: false,
  timing: false,
  // Override used node-fetch
  fetch: undefined,
  // Additional labels to apply to each timeseries, i.e. [{ service: "SQS" }]
  labels: undefined
};

// Follows remote_write payload format (see https://github.com/prometheus/prometheus/blob/main/prompb/types.proto)
await pushTimeseries(
  {
    labels: {
      __name__: "queue_depth_total",
      instance: "dev.example.com",
      service: "SQS",
    },
    samples: [
      {
        value: 150,
        timestamp: Date.now(),
      },
    ],
  },
  config
)

// Simpler push 
await pushMetrics({ queue_depth_total: 150 }, config)

Links

About

Send samples to prometheus via remote_write from NodeJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%