Need help with development of a custom plugin #746
-
Hi, I would like to play around with the IF. For this I need to get my data from a Prometheus server. So I decided to start writing a simple plugin. Unfortunately I got stuck very early. I followed the instructions from the documentation and the content from the README in the if-plugin-template. I did only minimal changes like renaming the package and did not implement any logic yet. I can run the tests and call the plugin as program. However I can not manage to start the plugin in context of the IF. When I run IF with a minimal manifest file which uses my plugin I get the following error. I am no expert on javascript/typescript but my guess is this is a very basic issue: [2024-05-30 09:02:32.070 PM] error: Cannot read properties of undefined (reading 'length')
TypeError: Cannot read properties of undefined (reading 'length')
at computeNode (/Users/tirlaender/Werkbank/if-prometheus-importer/node_modules/@grnsft/if/build/lib/compute.js:52:25)
at traverse (/Users/tirlaender/Werkbank/if-prometheus-importer/node_modules/@grnsft/if/build/lib/compute.js:11:15)
at computeNode (/Users/tirlaender/Werkbank/if-prometheus-importer/node_modules/@grnsft/if/build/lib/compute.js:42:16)
at compute (/Users/tirlaender/Werkbank/if-prometheus-importer/node_modules/@grnsft/if/build/lib/compute.js:79:11)
at impactEngine (/Users/tirlaender/Werkbank/if-prometheus-importer/node_modules/@grnsft/if/build/index.js:27:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) The code is availabe here: https://github.com/toirl/if-prometheus-importer/tree/step/0-Install. Detailed description of what I did can be found here: https://publish.obsidian.md/toirl/01+Efforts/🔥+Active/Green+Software/HTMCE+-+Writing+a+IF+plugin+to+import+data+from+Prometheus Is here anyone how can help be a little bit on this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @toirl Your plugin code expects to receive some global config, which you need to provide int he plugin's |
Beta Was this translation helpful? Give feedback.
Hi @toirl
Seems like you are not passing any config or input values from your manifest to the plugin.
Your plugin code expects to receive some global config, which you need to provide int he plugin's
initialize
block. Then you need to add some data to your manifest so the plugin has something to operate over. If you check your typescript script that invoked the plugin you'll see the input data being passed in ({timestamp...
} and the global config being passed as an empty object{}
.The plugin has to receive something for its expected fields even if that something is an empty object.