From e338c982d2c271d96063f89336bb1007c509cf96 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Mon, 7 Nov 2022 22:41:52 +0100 Subject: [PATCH] Prometheus wants counter, not count --- src/prometheus.ts | 2 +- tests/prometheus.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prometheus.ts b/src/prometheus.ts index d9e618a..e54270b 100644 --- a/src/prometheus.ts +++ b/src/prometheus.ts @@ -50,7 +50,7 @@ export class MetricsRenderer { render(metric: Metric): string { const name = this.metricName(metric.name) return [ - `# TYPE ${name} ${name.endsWith('_total') ? 'count' : 'gauge'}`, + `# TYPE ${name} ${name.endsWith('_total') ? 'counter' : 'gauge'}`, `${name}${this.renderLabels(metric.labels)} ${metric.value}${ metric.timestamp !== null ? ' ' + String(metric.timestamp.getTime()) : '' }`, diff --git a/tests/prometheus.test.ts b/tests/prometheus.test.ts index 79d8e2f..88a8d3c 100644 --- a/tests/prometheus.test.ts +++ b/tests/prometheus.test.ts @@ -37,7 +37,7 @@ prefix_metric{label="Some Label"} 0.000001 946684800000`, new Metric(metricName, 42, new Date('2000-01-01 00:00:00 UTC'), { label: 'Some Label' }), ), ).toEqual( - `# TYPE prefix_some_metric_total count + `# TYPE prefix_some_metric_total counter prefix_some_metric_total{label="Some Label"} 42 946684800000`, ) }