@theotherwillembotha/node-red-plugincore 0.0.50 → 0.0.52
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/README.md +155 -23
- package/build/GenerateNodes.js +3 -0
- package/build/Nodes.html +174 -250
- package/build/Nodes.js +2 -0
- package/build/core/NodeConstructor.d.ts +4 -2
- package/build/core/NodeConstructor.d.ts.map +1 -1
- package/build/core/NodeConstructor.js +5 -3
- package/build/core/NodeGenerator.js +8 -8
- package/build/core/logger/node/ConsoleLoggerConfigNode.html +20 -61
- package/build/core/logger/node/LokiLoggerConfigNode.d.ts +1 -1
- package/build/core/logger/node/LokiLoggerConfigNode.html +37 -73
- package/build/core/logger/node/LokiLoggerConfigNode.js +1 -1
- package/build/core/logger/node/RestLoggerConfigNode.html +51 -77
- package/build/core/logger/node/RestLoggerConfigNode.js +1 -1
- package/build/core/logger/service/LoggerService.d.ts +1 -1
- package/build/core/logger/service/LoggerService.d.ts.map +1 -1
- package/build/core/logger/service/LoggerService.js +2 -3
- package/build/core/logger/template/LoggerTemplate.d.ts.map +1 -1
- package/build/core/logger/template/LoggerTemplate.html +15 -12
- package/build/core/logger/template/LoggerTemplate.js +1 -2
- package/build/core/metrics/MetricsDecorator.js +2 -2
- package/build/core/metrics/node/CounterMetricConfigNode.html +2 -2
- package/build/core/metrics/node/GaugeMetricConfigNode.html +2 -2
- package/build/core/metrics/node/GaugeMetricConfigNode.js +2 -2
- package/build/core/metrics/node/MetricsConfigNode.html +1 -1
- package/build/core/metrics/node/TimerMetricConfigNode.html +13 -13
- package/build/core/metrics/service/MetricsService.d.ts +1 -1
- package/build/core/metrics/service/MetricsService.js +6 -6
- package/build/core/metrics/template/CounterMetricTemplate.html +1 -1
- package/build/core/metrics/template/GaugeMetricTemplate.html +1 -1
- package/build/core/metrics/template/TimerMetricTemplate.html +1 -1
- package/build/core/other/node/DelegatedConfigReferenceNode.d.ts +57 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.d.ts.map +1 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.html +1 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.js +79 -0
- package/build/core/tagging/NodeDescriptionDecorator.js +1 -1
- package/build/core/tagging/service/NodeTypeService.js +1 -1
- package/build/core/ui/template/UIHelperTemplate.d.ts +5 -0
- package/build/core/ui/template/UIHelperTemplate.d.ts.map +1 -0
- package/build/core/ui/template/UIHelperTemplate.html +229 -0
- package/build/core/ui/template/UIHelperTemplate.js +11 -0
- package/build/core/webhook/node/WebhookServerConfigNode.html +5 -5
- package/build/core/webhook/template/WebhookTemplate.html +18 -10
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/documentation/ConsoleLoggerConfigNode.png +0 -0
- package/documentation/CounterMetricConfigNode.png +0 -0
- package/documentation/GaugeMetricConfigNode.png +0 -0
- package/documentation/LokiLoggerConfigNode.png +0 -0
- package/documentation/MetricsConfigNode.png +0 -0
- package/documentation/RestLoggerConfigNode.png +0 -0
- package/documentation/TimerMetricConfigNode.png +0 -0
- package/documentation/WebhookNode.png +0 -0
- package/package.json +20 -8
- package/src/GenerateNodes.ts +5 -2
- package/src/core/NodeConstructor.ts +7 -4
- package/src/core/NodeGenerator.ts +8 -8
- package/src/core/logger/node/ConsoleLoggerConfigNode.html +20 -61
- package/src/core/logger/node/LokiLoggerConfigNode.html +37 -73
- package/src/core/logger/node/LokiLoggerConfigNode.ts +2 -2
- package/src/core/logger/node/RestLoggerConfigNode.html +51 -77
- package/src/core/logger/node/RestLoggerConfigNode.ts +1 -1
- package/src/core/logger/service/LoggerService.ts +3 -4
- package/src/core/logger/template/LoggerTemplate.html +15 -12
- package/src/core/logger/template/LoggerTemplate.ts +1 -2
- package/src/core/metrics/MetricsDecorator.ts +2 -2
- package/src/core/metrics/node/CounterMetricConfigNode.html +2 -2
- package/src/core/metrics/node/GaugeMetricConfigNode.html +2 -2
- package/src/core/metrics/node/GaugeMetricConfigNode.ts +2 -2
- package/src/core/metrics/node/MetricsConfigNode.html +1 -1
- package/src/core/metrics/node/MetricsConfigNode.ts +1 -1
- package/src/core/metrics/node/TimerMetricConfigNode.html +13 -13
- package/src/core/metrics/service/MetricsService.ts +6 -6
- package/src/core/metrics/template/CounterMetricTemplate.html +1 -1
- package/src/core/metrics/template/GaugeMetricTemplate.html +1 -1
- package/src/core/metrics/template/TimerMetricTemplate.html +1 -1
- package/src/core/other/node/DelegatedConfigReferenceNode.html +1 -0
- package/src/core/other/node/DelegatedConfigReferenceNode.ts +70 -0
- package/src/core/tagging/NodeDescriptionDecorator.ts +1 -1
- package/src/core/tagging/service/NodeTypeService.ts +1 -1
- package/src/core/ui/template/UIHelperTemplate.html +229 -0
- package/src/core/ui/template/UIHelperTemplate.ts +14 -0
- package/src/core/webhook/node/WebhookServerConfigNode.html +5 -5
- package/src/core/webhook/template/WebhookTemplate.html +18 -10
- package/src/index.ts +3 -1
- package/build/core/logger/node/LoggerConfigNode.d.ts +0 -30
- package/build/core/logger/node/LoggerConfigNode.d.ts.map +0 -1
- package/build/core/logger/node/LoggerConfigNode.html +0 -307
- package/build/core/logger/node/LoggerConfigNode.js +0 -60
- package/src/core/logger/node/LoggerConfigNode.html +0 -307
- package/src/core/logger/node/LoggerConfigNode.ts +0 -95
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theotherwillembotha/node-red-plugincore",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "0.0.52",
|
|
4
|
+
"description": "A core framework for building production-grade Node-RED plugins, with built-in support for structured logging, metrics, and webhook ingestion.",
|
|
5
5
|
"author": "Willem Botha (@theotherwillembotha)",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"keywords": [
|
|
8
|
-
"node-red",
|
|
8
|
+
"node-red",
|
|
9
|
+
"logging",
|
|
10
|
+
"metrics",
|
|
11
|
+
"webhook",
|
|
12
|
+
"reverseproxy"
|
|
9
13
|
],
|
|
10
14
|
"main": "./build/index.js",
|
|
11
15
|
"exports": "./build/index.js",
|
|
@@ -20,13 +24,20 @@
|
|
|
20
24
|
},
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/theotherwillembotha/nodered_plugincore.git"
|
|
27
|
+
"url": "git+https://github.com/theotherwillembotha/nodered_plugincore.git"
|
|
24
28
|
},
|
|
25
29
|
"bugs": {
|
|
26
30
|
"url": "https://github.com/theotherwillembotha/nodered_plugincore/issues"
|
|
27
31
|
},
|
|
28
32
|
"types": "./build/index.d.ts",
|
|
29
|
-
"files": [
|
|
33
|
+
"files": [
|
|
34
|
+
"build/",
|
|
35
|
+
"src/",
|
|
36
|
+
"icons/",
|
|
37
|
+
"documentation/",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
30
41
|
"homepage": "https://github.com/theotherwillembotha/nodered_plugincore#readme",
|
|
31
42
|
"engines": {
|
|
32
43
|
"node": ">=18",
|
|
@@ -35,7 +46,7 @@
|
|
|
35
46
|
"devDependencies": {
|
|
36
47
|
"@types/deep-equal": "^1.0.4",
|
|
37
48
|
"@types/js-beautify": "^1.14.3",
|
|
38
|
-
"@types/jsdom": "^
|
|
49
|
+
"@types/jsdom": "^28.0.3",
|
|
39
50
|
"@types/markdown-it": "^14.1.2",
|
|
40
51
|
"@types/node": "^22.15.29",
|
|
41
52
|
"@types/node-red": "~1.3.5",
|
|
@@ -47,16 +58,17 @@
|
|
|
47
58
|
"express": "^5.1.0",
|
|
48
59
|
"handlebars": "^4.7.8",
|
|
49
60
|
"js-beautify": "^1.15.4",
|
|
50
|
-
"jsdom": "^
|
|
61
|
+
"jsdom": "^29.1.1",
|
|
51
62
|
"markdown-it": "^14.1.0",
|
|
52
63
|
"network": "^0.7.0",
|
|
53
64
|
"prom-client": "^15.1.3",
|
|
54
65
|
"reflect-metadata": "^0.2.2",
|
|
55
|
-
"whatwg-url": "^
|
|
66
|
+
"whatwg-url": "^16.0.1",
|
|
56
67
|
"winston": "^3.17.0",
|
|
57
68
|
"winston-loki": "^6.1.3"
|
|
58
69
|
},
|
|
59
70
|
"node-red": {
|
|
71
|
+
"version": ">=4.0.0",
|
|
60
72
|
"nodes": {
|
|
61
73
|
"core": "./build/Nodes.js"
|
|
62
74
|
},
|
package/src/GenerateNodes.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
import { DelegatedConfigReferenceNode } from "./core/other/node/DelegatedConfigReferenceNode.js";
|
|
2
3
|
import { NodeTypeService } from "./core/tagging/service/NodeTypeService.js";
|
|
3
|
-
import { NodeGenerator, SettingsService, BasicTemplate, SettingsTemplate, TimerMetricTemplate, ConsoleLoggerConfigNode, RestLoggerConfigNode, LokiLoggerConfigNode } from "./index.js"
|
|
4
|
+
import { NodeGenerator, SettingsService, BasicTemplate, SettingsTemplate, TimerMetricTemplate, ConsoleLoggerConfigNode, RestLoggerConfigNode, LokiLoggerConfigNode, UIHelperTemplate } from "./index.js"
|
|
4
5
|
import { WebhookServerConfigNode, WebhookServerService, WebhookTemplate, } from "./index.js"
|
|
5
6
|
|
|
6
|
-
import {LoggerService, LoggerTemplate
|
|
7
|
+
import {LoggerService, LoggerTemplate } from "./index.js";
|
|
7
8
|
|
|
8
9
|
import { MetricsService, MetricsTemplate, CounterMetricTemplate, GaugeMetricTemplate} from "./index.js";
|
|
9
10
|
import { MetricsConfigNode, GaugeMetricConfigNode, TimerMetricConfigNode, CounterMetricConfigNode } from "./index.js";
|
|
@@ -25,8 +26,10 @@ new NodeGenerator("./src/core/")
|
|
|
25
26
|
.registerTemplate(GaugeMetricTemplate)
|
|
26
27
|
.registerTemplate(TimerMetricTemplate)
|
|
27
28
|
.registerTemplate(WebhookTemplate)
|
|
29
|
+
.registerTemplate(UIHelperTemplate)
|
|
28
30
|
|
|
29
31
|
// nodes
|
|
32
|
+
.registerNode(DelegatedConfigReferenceNode)
|
|
30
33
|
.registerNode(ConsoleLoggerConfigNode)
|
|
31
34
|
.registerNode(RestLoggerConfigNode)
|
|
32
35
|
.registerNode(LokiLoggerConfigNode)
|
|
@@ -79,15 +79,17 @@ export type NodeDependencyType = INamedType & (INodeClass | IServiceClass);
|
|
|
79
79
|
|
|
80
80
|
export class NodeDescriptor {
|
|
81
81
|
private _group:string;
|
|
82
|
-
private
|
|
82
|
+
private _id:string;
|
|
83
|
+
private _name:String;
|
|
83
84
|
private _sourceFile: string;
|
|
84
85
|
private _dependencies: DependencyType[] = []
|
|
85
86
|
private _templates:{template:ITemplateClass, config:TemplateConfig}[] = [];
|
|
86
87
|
private _package: string;
|
|
87
88
|
private _tags: string[] = [];
|
|
88
89
|
|
|
89
|
-
constructor(group:string, name:string, sourceFile:string, pkg:string){
|
|
90
|
+
constructor(group:string, id:string, name:string, sourceFile:string, pkg:string){
|
|
90
91
|
this._group = group;
|
|
92
|
+
this._id = id;
|
|
91
93
|
this._name = name;
|
|
92
94
|
this._sourceFile = sourceFile;
|
|
93
95
|
this._package = pkg;
|
|
@@ -114,6 +116,7 @@ export class NodeDescriptor {
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
public group(){ return this._group; }
|
|
119
|
+
public id(){ return this._id; }
|
|
117
120
|
public name(){ return this._name; }
|
|
118
121
|
public sourceFile() { return this._sourceFile; }
|
|
119
122
|
public package() { return this._package; }
|
|
@@ -857,7 +860,7 @@ let evalInContext = (context: any, js: string) => {
|
|
|
857
860
|
let buildNode = function(node:INodeClass){
|
|
858
861
|
// get the node descriptor and create the builder.
|
|
859
862
|
let nodeDescriptor = node.getNodeDescriptor();
|
|
860
|
-
let nodeBuilder = new NodeBuilder(nodeDescriptor.
|
|
863
|
+
let nodeBuilder = new NodeBuilder(nodeDescriptor.id(), nodeDescriptor.group());
|
|
861
864
|
|
|
862
865
|
// load the html source file
|
|
863
866
|
let uiDom = new JSDOM(fs.readFileSync(nodeDescriptor.sourceFile()));
|
|
@@ -873,7 +876,7 @@ let buildNode = function(node:INodeClass){
|
|
|
873
876
|
Object.values(sections).forEach(section => {
|
|
874
877
|
let sectionData = uiDom.window.document.querySelector(`[template-section='on${section}']`)?.innerHTML;
|
|
875
878
|
if(sectionData){
|
|
876
|
-
(nodeBuilder as any)[`add${section}`](nodeDescriptor.
|
|
879
|
+
(nodeBuilder as any)[`add${section}`](nodeDescriptor.id(), sectionData);
|
|
877
880
|
}
|
|
878
881
|
});
|
|
879
882
|
|
|
@@ -76,8 +76,8 @@ class NodeGenerator {
|
|
|
76
76
|
try{
|
|
77
77
|
// verify that we have dont already have this node.
|
|
78
78
|
let descriptor = node.getNodeDescriptor();
|
|
79
|
-
if(!this._nodes[descriptor.
|
|
80
|
-
this._nodes[descriptor.
|
|
79
|
+
if(!this._nodes[descriptor.id()]){
|
|
80
|
+
this._nodes[descriptor.id()] = {nodeClass:node, descriptor:descriptor};
|
|
81
81
|
// skip the recursive dependencies for now.
|
|
82
82
|
//descriptor.dependencies().forEach(dependency => this.addDependency(dependency));
|
|
83
83
|
}
|
|
@@ -117,7 +117,7 @@ class NodeGenerator {
|
|
|
117
117
|
// STEP 2. compose the HTMLStructure of each of the nodes.
|
|
118
118
|
let nodeHTMLOutut = Object.values(this._nodes)
|
|
119
119
|
.map(node => {
|
|
120
|
-
console.log(`Processing node: ${node.descriptor.
|
|
120
|
+
console.log(`Processing node: ${node.descriptor.id()}`);
|
|
121
121
|
|
|
122
122
|
return buildNode(node.nodeClass);
|
|
123
123
|
})
|
|
@@ -136,7 +136,7 @@ ${nodeHTMLOutut}
|
|
|
136
136
|
// 1. get a list of the files to import.
|
|
137
137
|
let importList = [
|
|
138
138
|
...Object.values(this._nodes).map(node => {
|
|
139
|
-
return `const ${node.descriptor.
|
|
139
|
+
return `const ${node.descriptor.id()} = require("${node.descriptor.package()}").${node.descriptor.id()};`;
|
|
140
140
|
//let nodeFile = "./" + node.group() + "/" + node.sourceFile();
|
|
141
141
|
//return `const ${node.name()} = require("${nodeFile}");`;
|
|
142
142
|
}),
|
|
@@ -145,7 +145,7 @@ ${nodeHTMLOutut}
|
|
|
145
145
|
|
|
146
146
|
// 2. get the exported modules that have to be regestered by the node manager.
|
|
147
147
|
let moduleExports = Object.values(this._nodes).map(node => {
|
|
148
|
-
return ` manager.registerNodeType("${node.descriptor.
|
|
148
|
+
return ` manager.registerNodeType("${node.descriptor.id()}", ${node.descriptor.id()});`;
|
|
149
149
|
}).join("\n");
|
|
150
150
|
|
|
151
151
|
fs.writeFileSync(nodesOutputFile + ".js", `
|
|
@@ -162,7 +162,7 @@ ${moduleExports}
|
|
|
162
162
|
|
|
163
163
|
`);
|
|
164
164
|
|
|
165
|
-
console.log(`Done building ${Object.keys(this._nodes).length} nodes\n${Object.values(this._nodes).map(node => " - " + node.descriptor.
|
|
165
|
+
console.log(`Done building ${Object.keys(this._nodes).length} nodes\n${Object.values(this._nodes).map(node => " - " + node.descriptor.id() + "\n").join("")}\n`);
|
|
166
166
|
|
|
167
167
|
let serviceExports = this._services.map(service => {
|
|
168
168
|
return ` manager.registerService(${service.name()}.${service.name()});`
|
|
@@ -243,10 +243,10 @@ module.exports = function (RED) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
private static generateHeader(node:NodeDescriptor){
|
|
246
|
-
let padding = ' '.repeat(Math.max(0, Math.floor(NodeGenerator.headerWidth - node.
|
|
246
|
+
let padding = ' '.repeat(Math.max(0, Math.floor(NodeGenerator.headerWidth - node.id().length)/2 ));
|
|
247
247
|
return `
|
|
248
248
|
<!-- *${'*'.repeat(NodeGenerator.headerWidth)}* -->
|
|
249
|
-
<!-- ${padding} ${node.
|
|
249
|
+
<!-- ${padding} ${node.id()} ${padding} -->
|
|
250
250
|
<!-- *${'*'.repeat(NodeGenerator.headerWidth)}* -->
|
|
251
251
|
`;
|
|
252
252
|
}
|
|
@@ -46,86 +46,45 @@
|
|
|
46
46
|
<script type="text/html" template-section="onIncludeEditForm">
|
|
47
47
|
<div id="LoggerConfig">
|
|
48
48
|
<div class="form-row">
|
|
49
|
-
<label for="node-config-input-name"><i class="fa fa-
|
|
49
|
+
<label class="towb_editorlabel" for="node-config-input-name"><i class="fa fa-font"></i> Name</label>
|
|
50
50
|
<input type="text" id="node-config-input-name" />
|
|
51
51
|
</div>
|
|
52
52
|
|
|
53
53
|
<div class="form-row">
|
|
54
|
-
<label for="node-config-input-level"><i class="fa fa-
|
|
54
|
+
<label class="towb_editorlabel" for="node-config-input-level"><i class="fa fa-signal"></i> Level</label>
|
|
55
55
|
<input type="text" id="node-config-input-level" />
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
58
|
<div class="form-row">
|
|
59
|
-
<label for="node-config-input-templateEditor"><i class="fa fa-
|
|
59
|
+
<label class="towb_editorlabel" for="node-config-input-templateEditor"><i class="fa fa-code"></i> Template</label>
|
|
60
60
|
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
<script type="text/markdown" template-section="onIncludeDocumentation">
|
|
66
|
-
|
|
66
|
+
Writes log output to the Node-RED runtime console (stdout). Suitable for local development and containerised environments where stdout is captured.
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
: *name*
|
|
70
|
-
: *level*
|
|
71
|
-
: *
|
|
72
|
-
: *template*(mustache) : A template for the log messages.
|
|
68
|
+
### Properties
|
|
69
|
+
: *name* (string) : A descriptive name for this logger configuration.
|
|
70
|
+
: *level* (level) : The minimum log level. Messages below this threshold are suppressed. Options: DEBUG, INFO, WARNING, ERROR.
|
|
71
|
+
: *template* (mustache) : A Mustache/Handlebars template that formats the log message body.
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
### Mustache Templating
|
|
74
|
+
Mustache/Handlebars templates build the message string written to the console.
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
The
|
|
76
|
+
#### Provided Properties
|
|
77
|
+
: *msg* (object) : The Node-RED message object passed through the node.
|
|
78
|
+
: *currentTime* (string) : The current time in ISO 8601 format.
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
#### Helpers
|
|
81
|
+
: *json* (helper) : Serialises an object to a JSON string using `JSON.stringify`.
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
|
|
83
|
+
#### Examples
|
|
84
|
+
- `{{{json msg}}}` — serialises the full message object as JSON.
|
|
86
85
|
|
|
87
|
-
####
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: *username* (string) : the username used for basic authentication
|
|
92
|
-
: *password* (string) : the password used for basic authentication
|
|
93
|
-
|
|
94
|
-
##### APIKey
|
|
95
|
-
Provides authentication using a matrix parameter, header or query parameter and an apikey
|
|
96
|
-
|
|
97
|
-
: *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
|
|
98
|
-
: *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
|
|
99
|
-
: *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
|
|
100
|
-
|
|
101
|
-
### Loki
|
|
102
|
-
Publish the message to a loki endpoint.
|
|
103
|
-
|
|
104
|
-
: *host* (string) : the host and port\ of the loki instance that it being logged to
|
|
105
|
-
: *tenant* (string) : the tenant id that will be used to log to
|
|
106
|
-
: *username* (string) : the username for the loki instance.
|
|
107
|
-
: *authtoken* (string) : the authtoken for the loki instance.
|
|
108
|
-
|
|
109
|
-
# Mustache Templating
|
|
110
|
-
Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
|
|
111
|
-
The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
|
|
112
|
-
|
|
113
|
-
### Provided Properties
|
|
114
|
-
A couple of values are provided to the logging context by default.
|
|
115
|
-
|
|
116
|
-
: *msg* (object) : an object containing the payload or message that should be parsed through the template.
|
|
117
|
-
: *currentTime* (object) : a string containing the current time in ISO8601 format
|
|
118
|
-
|
|
119
|
-
### Mustache Helpers
|
|
120
|
-
In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
|
|
121
|
-
|
|
122
|
-
: *json* (helper) : converts a json object to a string using the JSON.stringify method.
|
|
123
|
-
|
|
124
|
-
## Examples
|
|
125
|
-
- {{{json msg}}} - serializes the the msg object to json format.
|
|
126
|
-
|
|
127
|
-
# References
|
|
128
|
-
- [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
129
|
-
- [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
86
|
+
#### References
|
|
87
|
+
- [Mustache — Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
88
|
+
- [Mustache — Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
130
89
|
</script>
|
|
131
90
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
.addDefault("level", {value:"info", required:true})
|
|
7
7
|
|
|
8
8
|
.addDefault("loki_host", {})
|
|
9
|
-
.addDefault("
|
|
9
|
+
.addDefault("loki_tenantid", {})
|
|
10
10
|
.addDefault("loki_userid", {})
|
|
11
11
|
.addDefault("loki_authtoken", {})
|
|
12
12
|
|
|
@@ -51,103 +51,67 @@
|
|
|
51
51
|
<script type="text/html" template-section="onIncludeEditForm">
|
|
52
52
|
<div id="LoggerConfig">
|
|
53
53
|
<div class="form-row">
|
|
54
|
-
<label for="node-config-input-name"><i class="fa fa-
|
|
54
|
+
<label class="towb_editorlabel" for="node-config-input-name"><i class="fa fa-font"></i> Name</label>
|
|
55
55
|
<input type="text" id="node-config-input-name" />
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
58
|
<div class="form-row">
|
|
59
|
-
<label for="node-config-input-level"><i class="fa fa-
|
|
59
|
+
<label class="towb_editorlabel" for="node-config-input-level"><i class="fa fa-signal"></i> Level</label>
|
|
60
60
|
<input type="text" id="node-config-input-level" />
|
|
61
61
|
</div>
|
|
62
62
|
|
|
63
63
|
<div class="form-row">
|
|
64
|
-
<label for="node-config-input-loki_host"><i class="fa fa-
|
|
64
|
+
<label class="towb_editorlabel" for="node-config-input-loki_host"><i class="fa fa-server"></i> Host</label>
|
|
65
65
|
<input class="required" type="text" id="node-config-input-loki_host" />
|
|
66
66
|
</div>
|
|
67
67
|
<div class="form-row">
|
|
68
|
-
<label for="node-config-input-
|
|
69
|
-
<input class="" type="text" id="node-config-input-
|
|
68
|
+
<label class="towb_editorlabel" for="node-config-input-loki_tenantid"><i class="fa fa-building-o"></i> Tenant ID</label>
|
|
69
|
+
<input class="" type="text" id="node-config-input-loki_tenantid" />
|
|
70
70
|
</div>
|
|
71
71
|
<div class="form-row">
|
|
72
|
-
<label for="node-config-input-loki_userid"><i class="fa fa-
|
|
72
|
+
<label class="towb_editorlabel" for="node-config-input-loki_userid"><i class="fa fa-user"></i> Username</label>
|
|
73
73
|
<input class="" type="text" id="node-config-input-loki_userid" />
|
|
74
74
|
</div>
|
|
75
75
|
<div class="form-row">
|
|
76
|
-
<label for="node-config-input-loki_authtoken"><i class="fa fa-
|
|
76
|
+
<label class="towb_editorlabel" for="node-config-input-loki_authtoken"><i class="fa fa-key"></i> Auth Token</label>
|
|
77
77
|
<input class="" type="password" id="node-config-input-loki_authtoken" />
|
|
78
78
|
</div>
|
|
79
79
|
|
|
80
80
|
<div class="form-row">
|
|
81
|
-
<label for="node-config-input-templateEditor"><i class="fa fa-
|
|
81
|
+
<label class="towb_editorlabel" for="node-config-input-templateEditor"><i class="fa fa-code"></i> Template</label>
|
|
82
82
|
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
|
|
83
83
|
</div>
|
|
84
84
|
</div>
|
|
85
85
|
</script>
|
|
86
86
|
|
|
87
87
|
<script type="text/markdown" template-section="onIncludeDocumentation">
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: *name*
|
|
92
|
-
: *level*
|
|
93
|
-
: *
|
|
94
|
-
: *
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
: *
|
|
108
|
-
|
|
109
|
-
####
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
##### APIKey
|
|
117
|
-
Provides authentication using a matrix parameter, header or query parameter and an apikey
|
|
118
|
-
|
|
119
|
-
: *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
|
|
120
|
-
: *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
|
|
121
|
-
: *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
|
|
122
|
-
|
|
123
|
-
### Loki
|
|
124
|
-
Publish the message to a loki endpoint.
|
|
125
|
-
|
|
126
|
-
: *host* (string) : the host and port\ of the loki instance that it being logged to
|
|
127
|
-
: *tenant* (string) : the tenant id that will be used to log to
|
|
128
|
-
: *username* (string) : the username for the loki instance.
|
|
129
|
-
: *authtoken* (string) : the authtoken for the loki instance.
|
|
130
|
-
|
|
131
|
-
# Mustache Templating
|
|
132
|
-
Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
|
|
133
|
-
The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
|
|
134
|
-
|
|
135
|
-
### Provided Properties
|
|
136
|
-
A couple of values are provided to the logging context by default.
|
|
137
|
-
|
|
138
|
-
: *msg* (object) : an object containing the payload or message that should be parsed through the template.
|
|
139
|
-
: *currentTime* (object) : a string containing the current time in ISO8601 format
|
|
140
|
-
|
|
141
|
-
### Mustache Helpers
|
|
142
|
-
In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
|
|
143
|
-
|
|
144
|
-
: *json* (helper) : converts a json object to a string using the JSON.stringify method.
|
|
145
|
-
|
|
146
|
-
## Examples
|
|
147
|
-
- {{{json msg}}} - serializes the the msg object to json format.
|
|
148
|
-
|
|
149
|
-
# References
|
|
150
|
-
- [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
151
|
-
- [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
88
|
+
Pushes log messages to a Grafana Loki instance using the Loki HTTP API.
|
|
89
|
+
|
|
90
|
+
### Properties
|
|
91
|
+
: *name* (string) : A descriptive name for this logger configuration.
|
|
92
|
+
: *level* (level) : The minimum log level. Messages below this threshold are suppressed. Options: DEBUG, INFO, WARNING, ERROR.
|
|
93
|
+
: *host* (string) : The base URL of the Loki instance, including port (e.g. `http://localhost:3100`).
|
|
94
|
+
: *tenant ID* (string) : The tenant identifier for multi-tenant Loki deployments (`X-Scope-OrgID` header). Leave blank for single-tenant deployments.
|
|
95
|
+
: *username* (string) : Username for Loki authentication.
|
|
96
|
+
: *auth token* (string) : Authentication token or password for Loki.
|
|
97
|
+
: *template* (mustache) : A Mustache/Handlebars template that formats the log message body.
|
|
98
|
+
|
|
99
|
+
### Mustache Templating
|
|
100
|
+
Mustache/Handlebars templates build the message string pushed to Loki.
|
|
101
|
+
|
|
102
|
+
#### Provided Properties
|
|
103
|
+
: *msg* (object) : The Node-RED message object passed through the node.
|
|
104
|
+
: *currentTime* (string) : The current time in ISO 8601 format.
|
|
105
|
+
|
|
106
|
+
#### Helpers
|
|
107
|
+
: *json* (helper) : Serialises an object to a JSON string using `JSON.stringify`.
|
|
108
|
+
|
|
109
|
+
#### Examples
|
|
110
|
+
- `{{{json msg}}}` — serialises the full message object as JSON.
|
|
111
|
+
|
|
112
|
+
#### References
|
|
113
|
+
- [Grafana Loki — HTTP API](https://grafana.com/docs/loki/latest/reference/loki-http-api/)
|
|
114
|
+
- [Mustache — Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
115
|
+
- [Mustache — Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
152
116
|
</script>
|
|
153
117
|
|
|
@@ -15,7 +15,7 @@ interface LokiLoggerConfigNodeConfig extends ConfigNodeConfig {
|
|
|
15
15
|
loki_host:string,
|
|
16
16
|
loki_userid?:string,
|
|
17
17
|
loki_authtoken?:string,
|
|
18
|
-
|
|
18
|
+
loki_tenantid?:string
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@NodeDescription({
|
|
@@ -46,7 +46,7 @@ export class LokiLoggerConfigNode extends ConfigNode<LokiLoggerConfigNodeConfig>
|
|
|
46
46
|
host:config.loki_host,
|
|
47
47
|
userid:config.loki_userid,
|
|
48
48
|
authtoken:config.loki_authtoken,
|
|
49
|
-
tenantID:config.
|
|
49
|
+
tenantID:config.loki_tenantid,
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
this._logger = LoggerService.get(loggerConfig);
|