Giter Site home page Giter Site logo

thewebface / node-red-contrib-prometheus-exporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from docoyo/node-red-contrib-prometheus-exporter

0.0 0.0 0.0 22 KB

A NodeRED node which allows exporting Prometheus metrics from within flows.

License: Apache License 2.0

JavaScript 52.76% HTML 47.24%

node-red-contrib-prometheus-exporter's Introduction

node-red-contrib-prometheus-exporter

A NodeRED node which allows exporting Prometheus metrics from within flows.

Using this node for NodeRED, you can define your own Prometheus metrics which will become available over an HTTP endpoint. The endpoint can be polled from a Prometheus agent or Telegraf.

Supported metric types:

  • Counter
  • Gauge

Labels are supported for both metric types.

How to install

The preferred way of installing the node is to use the Palette Manager in NodeRED. Just seek for node-red-contrib-prometheus-exporter and follow the instructions.

Alternatively, you can also manually install the node permanently into your embedded NodeRED application with npm:

npm install node-red-contrib-prometheus-exporter

How to use

Configure a metric

From the Palette Manager, pull the node "prometheus out" in the network section into your flow.

In the editor of the metric node, create a new metric by clicking the pencil button next to the "Metric" drop down box. The config node editor will fire up.

In the config node editor, define the metric as you like. Name, help, and metric type are mandatory. Label names are optional. To learn more about Prometheus metrics, please refer to the Prometheus documentation.

Using the metric in a flow

After you have defined the metric, you can now feed the metric with values to actually populate the metrics output.

The node expects a message.payload as input with the following structure:

{
    "op": "inc",
    "val": 5,
    "labels": {
        "tag_1": "computer_123"
    }
}

Choose the op property from one of the following values:

  • For metrics of type Counter:
    • inc - Increases the counter by val (without specifying val, defaults to 1)
  • For metrics of type Gauge:
    • set - Sets the gauge to val (which is mandatory for this operation)
    • inc - Increases the gauge by val (without specifying val, defaults to 1)
    • dec - Decreases the gauge by val (without specifying val, defaults to 1)

As described above, the val property is mandatory or optional depending on the selected op and the metric type.

Labels are always optional. Make sure, you only use label keys, which you have defined in the configuration of the node as "Labels".

Check the metrics output

Deploy the flow, open up the browser and access the /metrics endpoint of your NodeRED server.

The output should look like this:

# HELP example_counter This is an example Counter
# TYPE example_counter counter
example_counter 10

# HELP example_gauge This is an example Gauge
# TYPE example_gauge gauge
example_gauge{tag_1="computer_123"} 5
example_gauge 5

Changing the path

You can manually change the path under which the metrics are exposed. Just set the environment variable PROMETHEUS_METRICS_PATH to a path of your choice.

Expose default metrics

You can easily collect and expose a useful set of pre-defined metrics about the node.js process hosting the NodeRED environment. These metrics are disabled by default, but you can activate them by setting the environment variable PROMETHEUS_COLLECT_DEFAULT_METRICS to true.

License

This library is licensed under Apache 2.0.

Credits

NodeRED is an awsome and carefully-written low-code environment for node.js. This library has been written and tested against NodeRED v1.2.

Under the hood, this library is built on top of the prom-client, a mature Prometheus client for node.js.

This project is sponsored by docoyo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.