@redkern/node-red-prometheus 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/LICENSE +188 -0
- package/README.md +176 -2
- package/SECURITY.md +18 -0
- package/examples/basic-metrics.json +131 -0
- package/examples/section-timer.json +138 -0
- package/lib/cardinality.js +71 -0
- package/lib/default-metrics.js +51 -0
- package/lib/palette.js +154 -0
- package/lib/receiver.js +169 -0
- package/lib/registry.js +241 -0
- package/lib/warn-once.js +20 -0
- package/nodes/icons/redkern-prom-exporter.svg +9 -0
- package/nodes/icons/redkern-prom-metric.svg +9 -0
- package/nodes/locales/en-US/prometheus.html +75 -0
- package/nodes/locales/en-US/prometheus.json +98 -0
- package/nodes/prometheus.html +415 -0
- package/nodes/prometheus.js +337 -0
- package/observability/grafana-dashboard.json +349 -0
- package/observability/prometheus-rule.yaml +42 -0
- package/package.json +74 -4
package/lib/registry.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createCardinalityGuard } = require('./cardinality.js');
|
|
4
|
+
|
|
5
|
+
// PRM-REG-1, PRM-REG-3, PRM-REG-4, PRM-REG-5: a palette-private Prometheus client Registry with
|
|
6
|
+
// ensure-semantics, owner reference counting and deferred removal across deploys.
|
|
7
|
+
|
|
8
|
+
const METRIC_NAME = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;
|
|
9
|
+
const LABEL_NAME = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
10
|
+
const RESERVED_LABELS = new Set(['le', 'quantile']);
|
|
11
|
+
const TYPES = Object.freeze(['counter', 'gauge', 'histogram', 'summary']);
|
|
12
|
+
const OPERATIONS = Object.freeze({
|
|
13
|
+
counter: Object.freeze(['inc']),
|
|
14
|
+
gauge: Object.freeze(['inc', 'dec', 'set']),
|
|
15
|
+
histogram: Object.freeze(['observe']),
|
|
16
|
+
summary: Object.freeze(['observe'])
|
|
17
|
+
});
|
|
18
|
+
const INTERNAL_PREFIX = 'redkern_prom_';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validates and normalizes a metric definition coming from a config node.
|
|
22
|
+
* @returns {{ ok: true, value: any } | { ok: false, errors: Array<{ field: string, code: string, message: string }> }}
|
|
23
|
+
*/
|
|
24
|
+
function normalizeDefinition(input) {
|
|
25
|
+
const errors = [];
|
|
26
|
+
const type = String(input.type || '');
|
|
27
|
+
const name = String(input.name || '').trim();
|
|
28
|
+
const labelNames = Array.isArray(input.labelNames) ? input.labelNames.map((label) => String(label).trim()).filter(Boolean) : [];
|
|
29
|
+
if (!TYPES.includes(type)) errors.push(issue('metricType', 'INVALID_TYPE', `Unsupported metric type "${type}"`));
|
|
30
|
+
if (!METRIC_NAME.test(name)) errors.push(issue('metricName', 'INVALID_NAME', `Metric "${name}" has an invalid Prometheus name`));
|
|
31
|
+
else if (name.startsWith(INTERNAL_PREFIX)) errors.push(issue('metricName', 'RESERVED_NAME', `Metric names starting with ${INTERNAL_PREFIX} are reserved`));
|
|
32
|
+
for (const label of labelNames) {
|
|
33
|
+
if (!LABEL_NAME.test(label) || label.startsWith('__')) errors.push(issue('labelNames', 'INVALID_LABEL', `Label "${label}" has an invalid Prometheus name`));
|
|
34
|
+
else if (RESERVED_LABELS.has(label)) errors.push(issue('labelNames', 'RESERVED_LABEL', `Label "${label}" is reserved by Prometheus`));
|
|
35
|
+
}
|
|
36
|
+
const duplicate = labelNames.find((label, index) => labelNames.indexOf(label) !== index);
|
|
37
|
+
if (duplicate) errors.push(issue('labelNames', 'DUPLICATE_LABEL', `Label "${duplicate}" is declared more than once`));
|
|
38
|
+
|
|
39
|
+
const value = {
|
|
40
|
+
type,
|
|
41
|
+
name,
|
|
42
|
+
help: String(input.help || '').trim() || name,
|
|
43
|
+
labelNames,
|
|
44
|
+
maxSeries: input.maxSeries,
|
|
45
|
+
allowlist: input.allowlist || {}
|
|
46
|
+
};
|
|
47
|
+
if (type === 'histogram') {
|
|
48
|
+
const buckets = numberList(input.buckets);
|
|
49
|
+
if (buckets === null) errors.push(issue('buckets', 'INVALID_BUCKETS', 'Buckets must be finite numbers'));
|
|
50
|
+
else if (buckets.length) {
|
|
51
|
+
if (buckets.some((bucket, index) => index > 0 && bucket <= buckets[index - 1])) {
|
|
52
|
+
errors.push(issue('buckets', 'INVALID_BUCKETS', 'Buckets must be strictly increasing'));
|
|
53
|
+
}
|
|
54
|
+
value.buckets = buckets;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (type === 'summary') {
|
|
58
|
+
const percentiles = numberList(input.percentiles);
|
|
59
|
+
if (percentiles === null || (percentiles && percentiles.some((p) => p <= 0 || p >= 1))) {
|
|
60
|
+
errors.push(issue('percentiles', 'INVALID_PERCENTILES', 'Percentiles must be numbers between 0 and 1'));
|
|
61
|
+
} else if (percentiles.length) value.percentiles = percentiles;
|
|
62
|
+
const hasMaxAge = input.maxAgeSeconds !== undefined && input.maxAgeSeconds !== null && String(input.maxAgeSeconds).trim() !== '' && Number(input.maxAgeSeconds) !== 0;
|
|
63
|
+
const maxAge = Number(input.maxAgeSeconds);
|
|
64
|
+
const ageBuckets = Number(input.ageBuckets);
|
|
65
|
+
if (hasMaxAge) {
|
|
66
|
+
if (!Number.isSafeInteger(maxAge) || maxAge < 1) errors.push(issue('maxAgeSeconds', 'INVALID_MAX_AGE', 'maxAgeSeconds must be a positive integer'));
|
|
67
|
+
else value.maxAgeSeconds = maxAge;
|
|
68
|
+
if (!Number.isSafeInteger(ageBuckets) || ageBuckets < 1) errors.push(issue('ageBuckets', 'INVALID_AGE_BUCKETS', 'ageBuckets must be a positive integer when maxAgeSeconds is set'));
|
|
69
|
+
else value.ageBuckets = ageBuckets;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const label of Object.keys(value.allowlist)) {
|
|
73
|
+
if (!labelNames.includes(label)) errors.push(issue('allowlist', 'UNKNOWN_LABEL', `Allowlist label "${label}" is not declared on the metric`));
|
|
74
|
+
}
|
|
75
|
+
return errors.length ? { ok: false, errors } : { ok: true, value };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function contractOf(definition) {
|
|
79
|
+
return JSON.stringify([
|
|
80
|
+
definition.type,
|
|
81
|
+
definition.labelNames,
|
|
82
|
+
definition.buckets || null,
|
|
83
|
+
definition.percentiles || null,
|
|
84
|
+
definition.maxAgeSeconds || null,
|
|
85
|
+
definition.ageBuckets || null
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {{ promClient: typeof import('@prometheus-io/client'), warn: (key: string, message: string) => void }} options
|
|
91
|
+
*/
|
|
92
|
+
function createMetricRegistry({ promClient, warn }) {
|
|
93
|
+
const registry = new promClient.Registry();
|
|
94
|
+
const entries = new Map();
|
|
95
|
+
const dropped = new promClient.Counter({
|
|
96
|
+
name: `${INTERNAL_PREFIX}dropped_series_total`,
|
|
97
|
+
help: 'New label combinations rejected because a metric reached maxSeriesPerMetric.',
|
|
98
|
+
labelNames: ['metric'],
|
|
99
|
+
registers: [registry]
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
function construct(definition) {
|
|
103
|
+
const options = {
|
|
104
|
+
name: definition.name,
|
|
105
|
+
help: definition.help,
|
|
106
|
+
labelNames: definition.labelNames,
|
|
107
|
+
registers: [registry]
|
|
108
|
+
};
|
|
109
|
+
if (definition.type === 'counter') return new promClient.Counter(options);
|
|
110
|
+
if (definition.type === 'gauge') return new promClient.Gauge(options);
|
|
111
|
+
if (definition.type === 'histogram') {
|
|
112
|
+
return new promClient.Histogram(definition.buckets ? { ...options, buckets: definition.buckets } : options);
|
|
113
|
+
}
|
|
114
|
+
const summary = { ...options };
|
|
115
|
+
if (definition.percentiles) summary.percentiles = definition.percentiles;
|
|
116
|
+
if (definition.maxAgeSeconds) {
|
|
117
|
+
summary.maxAgeSeconds = definition.maxAgeSeconds;
|
|
118
|
+
summary.ageBuckets = definition.ageBuckets;
|
|
119
|
+
}
|
|
120
|
+
return new promClient.Summary(summary);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function createEntry(definition) {
|
|
124
|
+
const entry = {
|
|
125
|
+
definition,
|
|
126
|
+
contract: contractOf(definition),
|
|
127
|
+
metric: construct(definition),
|
|
128
|
+
owners: new Set(),
|
|
129
|
+
guard: createCardinalityGuard({
|
|
130
|
+
labelNames: definition.labelNames,
|
|
131
|
+
maxSeries: definition.maxSeries,
|
|
132
|
+
allowlist: definition.allowlist,
|
|
133
|
+
onDrop: () => {
|
|
134
|
+
dropped.inc({ metric: definition.name });
|
|
135
|
+
if (entry.onDrop) for (const listener of entry.onDrop) listener();
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
onDrop: new Set()
|
|
139
|
+
};
|
|
140
|
+
entries.set(definition.name, entry);
|
|
141
|
+
return entry;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function removeEntry(name) {
|
|
145
|
+
entries.delete(name);
|
|
146
|
+
registry.removeSingleMetric(name);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
registry,
|
|
151
|
+
/**
|
|
152
|
+
* @returns {{ ok: true, handle: any } | { ok: false, code: string, message: string }}
|
|
153
|
+
*/
|
|
154
|
+
ensure(ownerId, definition) {
|
|
155
|
+
let entry = entries.get(definition.name);
|
|
156
|
+
const contract = contractOf(definition);
|
|
157
|
+
if (entry && entry.contract !== contract) {
|
|
158
|
+
if (entry.owners.size > 0 && !(entry.owners.size === 1 && entry.owners.has(ownerId))) {
|
|
159
|
+
return {
|
|
160
|
+
ok: false,
|
|
161
|
+
code: 'CONTRACT_CONFLICT',
|
|
162
|
+
message: `Metric "${definition.name}" is already defined with a different type, labels or buckets`
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
warn(`RECREATE:${definition.name}`, `Metric "${definition.name}" changed type, labels or buckets; it was recreated and its series were reset`);
|
|
166
|
+
removeEntry(definition.name);
|
|
167
|
+
entry = undefined;
|
|
168
|
+
}
|
|
169
|
+
if (!entry) entry = createEntry(definition);
|
|
170
|
+
else if (entry.owners.size === 0) entry.guard.update({ maxSeries: definition.maxSeries, allowlist: definition.allowlist });
|
|
171
|
+
else if (Number(entry.guard.limit) !== Number(definition.maxSeries ?? entry.guard.limit)) {
|
|
172
|
+
warn(`LIMIT:${definition.name}`, `Metric "${definition.name}" is shared by config nodes with different maxSeriesPerMetric; the first deployed value is kept`);
|
|
173
|
+
}
|
|
174
|
+
entry.owners.add(ownerId);
|
|
175
|
+
return { ok: true, handle: makeHandle(entry) };
|
|
176
|
+
},
|
|
177
|
+
/** Marks the owner as gone. The metric stays until sweep() so a redeploy keeps its series (PRM-REG-3). */
|
|
178
|
+
release(ownerId, name) {
|
|
179
|
+
const entry = entries.get(name);
|
|
180
|
+
if (!entry) return false;
|
|
181
|
+
return entry.owners.delete(ownerId);
|
|
182
|
+
},
|
|
183
|
+
/** Removes metrics that no deployed config node owns any more. Called after flows start. */
|
|
184
|
+
sweep() {
|
|
185
|
+
const removed = [];
|
|
186
|
+
for (const [name, entry] of entries) {
|
|
187
|
+
if (entry.owners.size === 0) {
|
|
188
|
+
removeEntry(name);
|
|
189
|
+
removed.push(name);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return removed;
|
|
193
|
+
},
|
|
194
|
+
has(name) { return entries.has(name); },
|
|
195
|
+
async metrics() { return registry.metrics(); }
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function makeHandle(entry) {
|
|
200
|
+
const { definition, metric, guard } = entry;
|
|
201
|
+
return {
|
|
202
|
+
name: definition.name,
|
|
203
|
+
type: definition.type,
|
|
204
|
+
labelNames: definition.labelNames,
|
|
205
|
+
supports(operation) {
|
|
206
|
+
return OPERATIONS[definition.type].includes(operation);
|
|
207
|
+
},
|
|
208
|
+
/**
|
|
209
|
+
* @returns {'ok' | 'dropped' | 'unsupported' | 'invalid'}
|
|
210
|
+
*/
|
|
211
|
+
write(operation, labels, value) {
|
|
212
|
+
if (!OPERATIONS[definition.type].includes(operation)) return 'unsupported';
|
|
213
|
+
if (!Number.isFinite(value)) return 'invalid';
|
|
214
|
+
if (definition.type === 'counter' && value < 0) return 'invalid';
|
|
215
|
+
const effective = guard.admit(labels);
|
|
216
|
+
if (!effective) return 'dropped';
|
|
217
|
+
if (definition.labelNames.length === 0) metric[operation](value);
|
|
218
|
+
else metric[operation](effective, value);
|
|
219
|
+
return 'ok';
|
|
220
|
+
},
|
|
221
|
+
onDrop(listener) {
|
|
222
|
+
entry.onDrop.add(listener);
|
|
223
|
+
return () => entry.onDrop.delete(listener);
|
|
224
|
+
},
|
|
225
|
+
get series() { return guard.size; }
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function numberList(value) {
|
|
230
|
+
if (value === undefined || value === null || value === '') return [];
|
|
231
|
+
const raw = Array.isArray(value) ? value : String(value).split(',');
|
|
232
|
+
const items = raw.map((item) => String(item).trim()).filter((item) => item.length > 0);
|
|
233
|
+
const numbers = items.map(Number);
|
|
234
|
+
return numbers.every(Number.isFinite) ? numbers : null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function issue(field, code, message) {
|
|
238
|
+
return { field, code, message };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
module.exports = { createMetricRegistry, normalizeDefinition, contractOf, numberList, TYPES, OPERATIONS, INTERNAL_PREFIX };
|
package/lib/warn-once.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Logs each key once, with a bounded memory: the set is cleared when it grows past `limit`, so a flow that
|
|
4
|
+
// produces unbounded distinct keys repeats a warning instead of leaking memory.
|
|
5
|
+
function createWarnOnce(warn, limit) {
|
|
6
|
+
const warned = new Set();
|
|
7
|
+
return (key, message) => {
|
|
8
|
+
if (warned.has(key)) return false;
|
|
9
|
+
if (warned.size >= limit) warned.clear();
|
|
10
|
+
warned.add(key);
|
|
11
|
+
warn(message, { key });
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function describeError(error) {
|
|
17
|
+
return error instanceof Error ? error.message : String(error);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { createWarnOnce, describeError };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="60" viewBox="0 0 40 60">
|
|
2
|
+
<title>Prometheus exporter</title>
|
|
3
|
+
<g fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.8">
|
|
4
|
+
<path d="M6 34a14 14 0 0 1 28 0"/>
|
|
5
|
+
<path d="M20 34l6-8"/>
|
|
6
|
+
<path d="M20 52V42m-5 5 5-5 5 5"/>
|
|
7
|
+
</g>
|
|
8
|
+
<circle cx="20" cy="34" r="2.2" fill="#fff"/>
|
|
9
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="60" viewBox="0 0 40 60">
|
|
2
|
+
<title>Prometheus metric</title>
|
|
3
|
+
<g fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.8">
|
|
4
|
+
<path d="M6 34a14 14 0 0 1 28 0"/>
|
|
5
|
+
<path d="M20 34l6-8"/>
|
|
6
|
+
<path d="M20 42v10m-5-5h10"/>
|
|
7
|
+
</g>
|
|
8
|
+
<circle cx="20" cy="34" r="2.2" fill="#fff"/>
|
|
9
|
+
</svg>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script type="text/html" data-help-name="redkern-prom-metric-config">
|
|
2
|
+
<p>Defines one Prometheus metric: counter, gauge, histogram or summary, with its labels and cardinality limit.</p>
|
|
3
|
+
<h3>Details</h3>
|
|
4
|
+
<p>Metrics live in the palette's own registry, not in the client global registry, so other palettes cannot clash with them.</p>
|
|
5
|
+
<p>Several config nodes with the same <b>Prometheus name</b> share one metric when their type, labels and buckets match.
|
|
6
|
+
A config node with the same name but a different contract shows a red status on the metric nodes that use it.</p>
|
|
7
|
+
<p>A redeploy without changes keeps the metric's series and counters. Changing the type, labels, buckets or percentiles
|
|
8
|
+
recreates the metric, with a warning in the log, and its series start from zero.</p>
|
|
9
|
+
<p><b>Also track duration</b> (counter only) adds a companion histogram <code><name without _total>_duration_seconds</code>
|
|
10
|
+
with the same labels; <i>observe</i> and <i>stop timer</i> on the counter write to it.</p>
|
|
11
|
+
<h3>Cardinality</h3>
|
|
12
|
+
<p><b>Max series</b> (default 1000) limits label combinations per metric. Existing series keep updating; new combinations
|
|
13
|
+
above the limit are dropped, counted in <code>redkern_prom_dropped_series_total{metric}</code>, and the metric nodes turn yellow.</p>
|
|
14
|
+
<p><b>Allowed values</b> lists the accepted values of a label. Any other value is written as <code>other</code>.</p>
|
|
15
|
+
<p>Never use IDs, UUIDs, timestamps or free text as label values.</p>
|
|
16
|
+
<h3>References</h3>
|
|
17
|
+
<ul>
|
|
18
|
+
<li><a href="https://prometheus.io/docs/practices/naming/">Prometheus naming practices</a></li>
|
|
19
|
+
<li><a href="https://github.com/redkern/node-red-prometheus">README</a></li>
|
|
20
|
+
</ul>
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script type="text/html" data-help-name="redkern-prom-metric">
|
|
24
|
+
<p>Writes a Prometheus metric for each message and forwards the message unchanged.</p>
|
|
25
|
+
<h3>Inputs</h3>
|
|
26
|
+
<dl class="message-properties">
|
|
27
|
+
<dt>any message</dt>
|
|
28
|
+
<dd>Each message triggers one metric write. Values and labels are read from the message, context or environment
|
|
29
|
+
as configured.</dd>
|
|
30
|
+
<dt class="optional">redkern.prom.timers <span class="property-type">object</span></dt>
|
|
31
|
+
<dd>Read by <i>Stop timer</i>.</dd>
|
|
32
|
+
</dl>
|
|
33
|
+
<h3>Outputs</h3>
|
|
34
|
+
<dl class="message-properties">
|
|
35
|
+
<dt>message <span class="property-type">object</span></dt>
|
|
36
|
+
<dd>The same message object. <i>Start timer</i> adds <code>msg.redkern.prom.timers[<key>]</code>
|
|
37
|
+
(milliseconds since the epoch); <i>Stop timer</i> removes it. Nothing else is changed.</dd>
|
|
38
|
+
</dl>
|
|
39
|
+
<h3>Details</h3>
|
|
40
|
+
<p>Actions: <b>Increment</b> (counter, gauge), <b>Decrement</b> and <b>Set</b> (gauge), <b>Observe</b> (histogram, summary,
|
|
41
|
+
or a counter with duration tracking), <b>Start timer</b> and <b>Stop timer and observe</b> to measure a part of the flow:
|
|
42
|
+
put the start node before the part and the stop node after it, using the same metric or the same timer key.</p>
|
|
43
|
+
<p>Values and labels accept <code>num</code>, <code>str</code>, <code>msg</code>, <code>flow</code>, <code>global</code>
|
|
44
|
+
and <code>env</code>. JSONata is not supported. Durations can be given in seconds or milliseconds.</p>
|
|
45
|
+
<p>Labels <code>step</code> (the node name, or a configured value), <code>status</code> (default <code>success</code>)
|
|
46
|
+
and <code>process</code> (the flow tab name) are filled automatically when the metric declares them.
|
|
47
|
+
Other declared labels are set in <b>Extra labels</b>. If a declared label has no value the write is skipped with a warning.</p>
|
|
48
|
+
<p>The node never stops the flow: a failed metric write is logged once and the message is still sent.
|
|
49
|
+
Messages are forwarded in arrival order unless a value comes from an asynchronous context store.</p>
|
|
50
|
+
<p>Status: yellow <i>dropped N</i> when the cardinality limit rejects series, red when the metric config is missing,
|
|
51
|
+
invalid or conflicts with another config node of the same name.</p>
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<script type="text/html" data-help-name="redkern-prom-exporter">
|
|
55
|
+
<p>Serves <code>/metrics</code> for Prometheus: this palette's metrics, default Node.js metrics and the metrics of other redkern palettes.</p>
|
|
56
|
+
<h3>Details</h3>
|
|
57
|
+
<p><b>Dedicated port</b> (default): the kit internal listener on port 9550 (<code>REDKERN_PROM_INTERNAL_PORT</code>)
|
|
58
|
+
at <code>/redkern/prom/metrics</code>. The public <code>httpNode</code> port is never used.</p>
|
|
59
|
+
<p>Authentication: Prometheus sends <code>Authorization: Bearer <token></code> with the value of
|
|
60
|
+
<code>REDKERN_PROM_METRICS_TOKEN</code> (32-4096 printable characters, not reused by other routes).
|
|
61
|
+
Without it the exporter stays red in this mode.</p>
|
|
62
|
+
<p><b>Node-RED admin API</b>: the same Node-RED port, <code>GET <httpAdminRoot>/redkern/prom/metrics</code> with
|
|
63
|
+
permission <code>redkern.prom.read</code>. Requires <code>adminAuth</code>; answers 503 when no exporter is active.</p>
|
|
64
|
+
<p>Only one exporter runs per Node-RED instance; a second one turns red and does not open a port.</p>
|
|
65
|
+
<p>Other redkern palettes (gateway, snowflake, redis, ...) register their metrics with this exporter automatically and
|
|
66
|
+
stop serving them on their own ports. A metric name that appears twice is served once, with a warning.</p>
|
|
67
|
+
<p><b>Collect default metrics</b> adds process, heap, GC and event-loop metrics with the <code>nodered_</code> prefix and
|
|
68
|
+
<code>nodered_flows_deploy_total</code>. <b>Add host label</b> duplicates the <code>pod</code> label from Kubernetes
|
|
69
|
+
service discovery and is off by default.</p>
|
|
70
|
+
<p><b>Include Prometheus client global registry</b> adds the global registry of this palette's own client copy.</p>
|
|
71
|
+
<h3>References</h3>
|
|
72
|
+
<ul>
|
|
73
|
+
<li><a href="https://github.com/redkern/node-red-prometheus#deployment">Scrape configuration and Helm values</a></li>
|
|
74
|
+
</ul>
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"redkern-prom": {
|
|
3
|
+
"paletteLabel": {
|
|
4
|
+
"metric": "metric",
|
|
5
|
+
"exporter": "exporter"
|
|
6
|
+
},
|
|
7
|
+
"label": {
|
|
8
|
+
"metric": "metric",
|
|
9
|
+
"metricConfig": "metric config",
|
|
10
|
+
"exporterPort": "exporter :__port__",
|
|
11
|
+
"exporterAdmin": "exporter (admin)"
|
|
12
|
+
},
|
|
13
|
+
"inputLabel": "message",
|
|
14
|
+
"outputLabel": "same message",
|
|
15
|
+
"section": {
|
|
16
|
+
"definition": "Metric definition",
|
|
17
|
+
"cardinality": "Cardinality",
|
|
18
|
+
"write": "Metric write",
|
|
19
|
+
"labels": "Labels",
|
|
20
|
+
"endpoint": "Prometheus endpoint",
|
|
21
|
+
"defaults": "Default metrics"
|
|
22
|
+
},
|
|
23
|
+
"field": {
|
|
24
|
+
"name": "Name",
|
|
25
|
+
"metricType": "Type",
|
|
26
|
+
"metricName": "Prometheus name",
|
|
27
|
+
"help": "Description",
|
|
28
|
+
"labelNames": "Label names",
|
|
29
|
+
"buckets": "Buckets",
|
|
30
|
+
"withDuration": "Also track duration",
|
|
31
|
+
"durationBuckets": "Duration buckets",
|
|
32
|
+
"percentiles": "Percentiles",
|
|
33
|
+
"maxAgeSeconds": "Max age, s",
|
|
34
|
+
"ageBuckets": "Age buckets",
|
|
35
|
+
"maxSeriesPerMetric": "Max series",
|
|
36
|
+
"allowlist": "Allowed values",
|
|
37
|
+
"metric": "Metric",
|
|
38
|
+
"operation": "Action",
|
|
39
|
+
"autoStep": "Use node name as step",
|
|
40
|
+
"step": "Step",
|
|
41
|
+
"status": "Status",
|
|
42
|
+
"value": "Value",
|
|
43
|
+
"duration": "Duration",
|
|
44
|
+
"timer": "Timer key",
|
|
45
|
+
"labels": "Extra labels",
|
|
46
|
+
"mode": "Serve on",
|
|
47
|
+
"includeGlobalRegistry": "Include Prometheus client global registry",
|
|
48
|
+
"defaultMetrics": "Collect default metrics",
|
|
49
|
+
"prefix": "Prefix",
|
|
50
|
+
"hostLabel": "Add host label"
|
|
51
|
+
},
|
|
52
|
+
"type": {
|
|
53
|
+
"counter": "Counter",
|
|
54
|
+
"gauge": "Gauge",
|
|
55
|
+
"histogram": "Histogram",
|
|
56
|
+
"summary": "Summary"
|
|
57
|
+
},
|
|
58
|
+
"operation": {
|
|
59
|
+
"inc": "Increment",
|
|
60
|
+
"dec": "Decrement",
|
|
61
|
+
"set": "Set",
|
|
62
|
+
"observe": "Observe",
|
|
63
|
+
"startTimer": "Start timer",
|
|
64
|
+
"stopTimer": "Stop timer and observe"
|
|
65
|
+
},
|
|
66
|
+
"mode": {
|
|
67
|
+
"internal": "Dedicated port",
|
|
68
|
+
"admin": "Node-RED admin API"
|
|
69
|
+
},
|
|
70
|
+
"unit": {
|
|
71
|
+
"seconds": "seconds",
|
|
72
|
+
"ms": "ms"
|
|
73
|
+
},
|
|
74
|
+
"placeholder": {
|
|
75
|
+
"metricName": "nodered_events_total",
|
|
76
|
+
"labelNames": "step,status,process",
|
|
77
|
+
"buckets": "0.005, 0.05, 0.5, 5",
|
|
78
|
+
"percentiles": "0.5, 0.9, 0.99",
|
|
79
|
+
"timer": "defaults to the metric config id",
|
|
80
|
+
"label": "label",
|
|
81
|
+
"values": "comma-separated values"
|
|
82
|
+
},
|
|
83
|
+
"hint": {
|
|
84
|
+
"metricName": "Changing the name, type, labels or buckets resets the metric's series.",
|
|
85
|
+
"labelNames": "Comma-separated. step, status and process are filled automatically.",
|
|
86
|
+
"maxSeries": "New label combinations above this limit are dropped and counted in redkern_prom_dropped_series_total.",
|
|
87
|
+
"allowlist": "Values outside the list are written as \"other\".",
|
|
88
|
+
"cardinality": "Keep label values bounded: never use IDs, UUIDs or timestamps.",
|
|
89
|
+
"token": "Requires REDKERN_PROM_METRICS_TOKEN: Prometheus sends it as Authorization: Bearer. Without it the exporter stays red; use the admin API mode instead.",
|
|
90
|
+
"port": "Kit internal listener on port 9550 (REDKERN_PROM_INTERNAL_PORT), path /redkern/prom/metrics.",
|
|
91
|
+
"admin": "Served at <httpAdminRoot>/redkern/prom/metrics with permission redkern.prom.read; requires adminAuth.",
|
|
92
|
+
"hostLabel": "Duplicates the pod label added by Kubernetes service discovery; enable only for dashboards that query host."
|
|
93
|
+
},
|
|
94
|
+
"button": {
|
|
95
|
+
"addAllowlist": "allowed values"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|