prom-client
Advanced tools
Comparing version 8.0.0 to 8.1.0
@@ -12,28 +12,32 @@ 'use strict'; | ||
var getMetrics = function getMetrics() { | ||
return getMetricsAsArray().reduce(function(acc, metric) { | ||
var item = metric.get(); | ||
var name = escapeString(item.name); | ||
var help = escapeString(item.help); | ||
help = ['#', 'HELP', name, help].join(' '); | ||
var type = ['#', 'TYPE', name, item.type].join(' '); | ||
function getMetricAsPrometheusString(metric) { | ||
var item = metric.get(); | ||
var name = escapeString(item.name); | ||
var help = escapeString(item.help); | ||
help = ['#', 'HELP', name, help].join(' '); | ||
var type = ['#', 'TYPE', name, item.type].join(' '); | ||
var values = (item.values || []).reduce(function(valAcc, val) { | ||
var labels = Object.keys(val.labels || {}).map(function(key) { | ||
return key + '="' + escapeLabelValue(val.labels[key]) + '"'; | ||
}); | ||
var values = (item.values || []).reduce(function(valAcc, val) { | ||
var labels = Object.keys(val.labels || {}).map(function(key) { | ||
return key + '="' + escapeLabelValue(val.labels[key]) + '"'; | ||
}); | ||
var metricName = val.metricName || item.name; | ||
if(labels.length) { | ||
metricName += '{' + labels.join(',') + '}'; | ||
} | ||
var metricName = val.metricName || item.name; | ||
if(labels.length) { | ||
metricName += '{' + labels.join(',') + '}'; | ||
} | ||
valAcc += [metricName, val.value].join(' '); | ||
valAcc += '\n'; | ||
return valAcc; | ||
}, ''); | ||
valAcc += [metricName, val.value].join(' '); | ||
valAcc += '\n'; | ||
return valAcc; | ||
}, ''); | ||
acc += [help, type, values].join('\n'); | ||
return acc; | ||
}, ''); | ||
var acc = [help, type, values].join('\n'); | ||
return acc; | ||
} | ||
var getMetrics = function getMetrics() { | ||
return getMetricsAsArray() | ||
.map(getMetricAsPrometheusString) | ||
.join('\n'); | ||
}; | ||
@@ -73,2 +77,6 @@ | ||
var getSingleMetricAsString = function getSingleMetricAsString(name) { | ||
return getMetricAsPrometheusString(metrics[name]); | ||
}; | ||
var getSingleMetric = function getSingleMetric(name) { | ||
@@ -85,3 +93,4 @@ return metrics[name]; | ||
getSingleMetric: getSingleMetric, | ||
getSingleMetricAsString: getSingleMetricAsString, | ||
contentType: 'text/plain; version=0.0.4; charset=utf-8' | ||
}; |
{ | ||
"name": "prom-client", | ||
"version": "8.0.0", | ||
"version": "8.1.0", | ||
"description": "Client for prometheus", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -204,2 +204,6 @@ # Prometheus client for node.js [![Build Status](https://travis-ci.org/siimon/prom-client.svg?branch=master)](https://travis-ci.org/siimon/prom-client) [![Build status](https://ci.appveyor.com/api/projects/status/k2e0gwonkcee3lp9/branch/master?svg=true)](https://ci.appveyor.com/project/siimon/prom-client/branch/master) | ||
##### Geting a single metric for Prometheus displaying | ||
If you need to output a single metric for Prometheus, you can use `register.getSingleMetricAsString(*name of metric*)`, it will output a string for Prometheus to consume. | ||
##### Getting a single metric | ||
@@ -216,3 +220,3 @@ | ||
It is possible to push metrics via a [Pushgateway](https://github.com/prometheus/pushgateway). | ||
It is possible to push metrics via a [Pushgateway](https://github.com/prometheus/pushgateway). | ||
@@ -237,3 +241,3 @@ ```js | ||
For convenience, there are 2 bucket generator functions - linear and exponential. | ||
For convenience, there are 2 bucket generator functions - linear and exponential. | ||
@@ -240,0 +244,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71380
1688
257