Transform a HCL Domino STATPUB file into Prometheus metrics

Inspired by this idea on the Domino Product Idea Portal I wanted to find a workaround.

In this workaround we will have a HCL Domino server write statistics into a text file every minute. We will transform this textfile so it matches a Prometheus metrics scrape file. This will allow Prometheus to store the Domino statistics in its time series database. You can then use these statistics in a Grafana dashboard. Node-Red

[{"id":"8a32fdd64fff0afd","type":"tab","label":"Domino Stats","disabled":false,"info":"","env":[]},{"id":"7dbdf6ef.a73868","type":"inject","z":"8a32fdd64fff0afd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"/var/log/stats","payloadType":"str","x":140,"y":200,"wires":[["6456763b.e07d78"]]},{"id":"dd9228cf.983768","type":"debug","z":"8a32fdd64fff0afd","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"combined","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":320,"wires":[]},{"id":"572a14c4.62aa3c","type":"debug","z":"8a32fdd64fff0afd","name":"Listing directory","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"files","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":240,"wires":[]},{"id":"20ef5f9.b8d63a","type":"debug","z":"8a32fdd64fff0afd","name":"array of files with meta info","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"stats","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":280,"wires":[]},{"id":"ee6515ea.f968c8","type":"function","z":"8a32fdd64fff0afd","name":"Combine and sort","func":"var combined = [];\n\nfor (var i = 0; i < msg.files.length; i++) {\n    var file = msg.files[i];\n    var stat = msg.stats[i];\n    \n    combined.push({\n        path: msg.payload,\n        file,\n        ...stat\n    })\n}\n\ncombined.sort((a, b) => b.birthtimeMs - a.birthtimeMs);\n\nmsg.combined = combined;\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":320,"wires":[["dd9228cf.983768","50034043.e2347"]]},{"id":"50034043.e2347","type":"change","z":"8a32fdd64fff0afd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"combined[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":360,"wires":[["4f9068e.e12c498","6e84ff0862e7ce27"]]},{"id":"4f9068e.e12c498","type":"debug","z":"8a32fdd64fff0afd","name":"newest file","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":360,"wires":[]},{"id":"35811671.90ebea","type":"fs-ops-stats","z":"8a32fdd64fff0afd","name":"","path":"payload","pathType":"msg","filename":"files","filenameType":"msg","stats":"stats","sizeType":"msg","x":180,"y":280,"wires":[["20ef5f9.b8d63a","ee6515ea.f968c8"]]},{"id":"6456763b.e07d78","type":"fs-ops-dir","z":"8a32fdd64fff0afd","name":"","path":"payload","pathType":"msg","filter":"*.prom","filterType":"str","dir":"files","dirType":"msg","x":160,"y":240,"wires":[["35811671.90ebea","572a14c4.62aa3c"]]},{"id":"9a4a7be02d623ece","type":"file in","z":"8a32fdd64fff0afd","name":"","filename":"","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":100,"y":460,"wires":[["be4b8a64269c46bc"]]},{"id":"989c8df9f3055ad4","type":"debug","z":"8a32fdd64fff0afd","name":"This is the newest file with full path","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":400,"wires":[]},{"id":"be4b8a64269c46bc","type":"csv","z":"8a32fdd64fff0afd","name":"","sep":" ","hdrin":false,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":false,"x":130,"y":500,"wires":[["e18b323ca32f3711","e643ac858bd57990"]]},{"id":"6e84ff0862e7ce27","type":"function","z":"8a32fdd64fff0afd","name":"","func":"const path = msg.payload.path;\nconst file = msg.payload.file;\nvar filename = path + '/' + file;\nmsg = {};\nmsg.filename = filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":400,"wires":[["989c8df9f3055ad4","9a4a7be02d623ece"]]},{"id":"e18b323ca32f3711","type":"debug","z":"8a32fdd64fff0afd","name":"Content of CSV file","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":500,"wires":[]},{"id":"e643ac858bd57990","type":"split","z":"8a32fdd64fff0afd","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":150,"y":540,"wires":[["75b57f750d549aad","81ef35157432f71f"]]},{"id":"75b57f750d549aad","type":"debug","z":"8a32fdd64fff0afd","name":"splits file into messages per line","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":540,"wires":[]},{"id":"81ef35157432f71f","type":"function","z":"8a32fdd64fff0afd","name":"","func":"var oldstring = msg.payload.col1;\nvar newstring;\n// ersetze Punkt durch Underscore\nnewstring = oldstring.replace(/\\./g,'_');\n// Entferne alles Slashes\nnewstring = newstring.replace(/\\//g,'');\n// ersetze Klammer auf durch Underscore\nnewstring = newstring.replace(/\\(/g,'_');\n// ersetze Klammer zu durch Underscore\nnewstring = newstring.replace(/\\)/g,'_');\nmsg.payload.col1 = newstring;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":180,"y":580,"wires":[["31d9355d01e4e9f4","d16d8821322f6d17"]]},{"id":"31d9355d01e4e9f4","type":"debug","z":"8a32fdd64fff0afd","name":"transform the key name","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":580,"wires":[]},{"id":"d16d8821322f6d17","type":"join","z":"8a32fdd64fff0afd","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":190,"y":620,"wires":[["f3269d008236a517","4b55a94a35e11733"]]},{"id":"f3269d008236a517","type":"debug","z":"8a32fdd64fff0afd","name":"re-join data into array","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":520,"y":620,"wires":[]},{"id":"4b55a94a35e11733","type":"csv","z":"8a32fdd64fff0afd","name":"","sep":" ","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":210,"y":660,"wires":[["5fc5750c21f84b4d","c72a8373ae4cd422"]]},{"id":"5fc5750c21f84b4d","type":"debug","z":"8a32fdd64fff0afd","name":"convert to CSV","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":660,"wires":[]},{"id":"c72a8373ae4cd422","type":"file","z":"8a32fdd64fff0afd","name":"","filename":"/metrics/metrics.csv","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":280,"y":700,"wires":[["122fc6fe03314fef"]]},{"id":"122fc6fe03314fef","type":"debug","z":"8a32fdd64fff0afd","name":"export to file","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":700,"wires":[]},{"id":"af7c2733d4499629","type":"catch","z":"8a32fdd64fff0afd","name":"","scope":null,"uncaught":false,"x":100,"y":120,"wires":[["3f4367ef27a1a46f"]]},{"id":"3f4367ef27a1a46f","type":"debug","z":"8a32fdd64fff0afd","name":"Error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":120,"wires":[]},{"id":"3d79c25616fcf9e3","type":"comment","z":"8a32fdd64fff0afd","name":"Domino notes.ini Settings","info":"STATPUB_ENABLE=1\nSTATPUB_URI=file:///../stats/domino_stats_$Timestamp$.prom\nSTATPUB_METRIC_FORMAT=$Name$ $Value$\nSTATPUB_METRIC_DELIMITER=$Newline$\nSTATPUB_DELTA_METRIC_FORMAT=PerMinuteStats.$Name$ $Value$\n","x":150,"y":60,"wires":[]}]

Flow Info

Created 2 years, 4 months ago
Rating: 1 1

Owner

Actions

Rate:

Node Types

Core
  • catch (x1)
  • change (x1)
  • comment (x1)
  • csv (x2)
  • debug (x12)
  • file (x1)
  • file in (x1)
  • function (x3)
  • inject (x1)
  • join (x1)
  • split (x1)
Other
  • fs-ops-dir (x1)
  • fs-ops-stats (x1)
  • tab (x1)

Tags

  • domino
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option