Gathering detailed insights and metrics for logzio-nodejs-metrics-alpha
Gathering detailed insights and metrics for logzio-nodejs-metrics-alpha
Gathering detailed insights and metrics for logzio-nodejs-metrics-alpha
Gathering detailed insights and metrics for logzio-nodejs-metrics-alpha
Records custom Prometheus format metrics in your Node js application and exports them to remote write compatible backends
npm install logzio-nodejs-metrics-alpha
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
84 Commits
3 Forks
4 Watchers
14 Branches
8 Contributors
Updated on Sep 17, 2024
Latest Version
0.3.1
Package Id
logzio-nodejs-metrics-alpha@0.3.1
Unpacked Size
59.16 kB
Size
13.17 kB
File Count
12
NPM Version
9.4.2
Node Version
16.17.0
Published on
Jul 19, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
12
This topic includes instructions on how to send custom metrics to Logz.io from your Node.js application.
The included example uses the OpenTelemetry JS SDK and its based on OpenTelemetry exporter collector proto.
Before you begin, you'll need: Node 8 or higher
Note This project works best with logzio as metrics backend, but its compatible with all backends that support prometheuesrmotewrite
format
Install the package:
npm install logzio-nodejs-metrics-sdk@0.3.0
Set the variables in the following code snippet:
Environment variable | Description |
---|---|
url | The Logz.io Listener URL for for your region, configured to use port 8052 for http traffic, or port 8053 for https traffic. For example - https://listener.logz.io:8053 |
token | Your Logz.io Prometheus Metrics account token. |
1const MeterProvider = require('@opentelemetry/sdk-metrics-base'); 2const sdk = require('logzio-nodejs-metrics-sdk'); 3 4const collectorOptions = { 5 url: '<<url>>', 6 headers: { 7 Authorization: 'Bearer <<token>>', 8 }, 9}; 10// Initialize the exporter 11const metricExporter = new sdk.RemoteWriteExporter(collectorOptions); 12 13// Initialize the meter provider 14const meter = new MeterProvider.MeterProvider({ 15 exporter: metricExporter, 16 interval: 15000, // Push interval in seconds 17}).getMeter('example-exporter'); 18 19// Create your first counter metric 20const requestCounter = meter.createCounter('Counter', { 21 description: 'Example of a Counter', 22}); 23// Define some labels for your metrics 24const labels = { environment: 'prod' }; 25// Record some value 26requestCounter.bind(labels).add(1); 27// In logzio Metrics you will see the following metric: 28// Counter_total{environment: 'prod'} 1.0
For more information, see the OpenTelemetry documentation.
Name | Behavior |
---|---|
Counter | Metric value can only go up or be reset to 0, calculated per counter.Add(context,value,labels) request. |
UpDownCounter | Metric value can arbitrarily increment or decrement, calculated per updowncounter.Add(context,value,labels) request. |
Histogram | Metric values captured by the histogram.Record(context,value,labels) function, calculated per request. |
First Initialize the exporter and meter provider:
1const MeterProvider = require('@opentelemetry/sdk-metrics-base'); 2const sdk = require('logzio-nodejs-metrics-sdk'); 3 4const collectorOptions = { 5 url: '<<url>>', 6 headers: { 7 Authorization: 'Bearer <<token>>', 8 }, 9}; 10// Initialize the exporter 11const metricExporter = new sdk.RemoteWriteExporter(collectorOptions); 12 13// Initialize the meter provider 14const meter = new MeterProvider.MeterProvider({ 15 exporter: metricExporter, 16 interval: 15000, // Push interval in seconds 17}).getMeter('example-exporter');
Then create different types of metrics
1// Create UpDownCounter metric 2const upDownCounter = meter.createUpDownCounter('UpDownCounter', { 3 description: 'Example of a UpDownCounter', 4}); 5// Define some labels for your metrics 6const labels = { environment: 'prod' }; 7// Record some values 8upDownCounter.bind(labels); 9upDownCounter.add(5); 10upDownCounter.add(-1); 11// In logzio you will see the following metric: 12// UpDownCounter{environment: 'prod'} 4.0
1// Create ValueRecorder metric 2const histogram = meter.createHistogram('test_histogram', { 3 description: 'Example of a histogram', 4}); 5// Define some labels for your metrics 6const labels = { environment: 'prod' }; 7// Record some values 8histogram.bind(labels); 9histogram.record(30); 10histogram.record(20); 11// In logzio you will see the following metrics: 12// test_histogram_sum{environment: 'prod'} 50.0 13// test_histogram_count{environment: 'prod'} 2.0 14// test_histogram_avg{environment: 'prod'} 25.0
0.3.0
0.2.0
0.1.0
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 4/8 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More