FlowFuse / flowfuse

Connect, collect, transform, visualise, and interact with your Industrial Data in a single platform. Use FlowFuse to manage, scale and secure your Node-RED solutions.
https://flowfuse.com
Other
281 stars 63 forks source link

Enable custom logging options for Node-RED instances #3324

Closed anthonyjsargeant closed 9 months ago

anthonyjsargeant commented 10 months ago

Description

In order to be able to persist Node-RED instance logs in an ELK stack, as a Developer, I would to be able to specify the log format and log output destination (e.g. stdout).

Once FlowFuse has provisioned an instance, the only place that the instance's logs can be viewed is through the FlowFuse UI and is in a fixed format. Ideally, I would like to be able to customise the logging options for the Node-RED instances such that the logs can be output to stdout and can be reformatted.

For example, I would like to be able to have the logs in Elastic Common Schema (ECS) format and output to stdout so that the logs can be consumed by our ELK stack. This would also ensure that the logs are persisted in case of any issues with Pod as only the last 1000 lines are stored in the pod's memory.

Given that I am not a member of FlowForge, I'm not able to provide an estimate, or decide on which customers this feature would be available to.

Which customers would this be available to

Other (See comments)

Have you provided an initial effort estimate for this issue?

I am not a FlowForge team member

robmarcer commented 10 months ago

This is https://app-eu1.hubspot.com/contacts/26586079/record/0-1/2461351

hardillb commented 10 months ago

Suggest for MVP implementation is to just enable pass through of the existing logging format we use to transport the logs to the cloud app. e.g.

{"ts":"17054205228370000","level":"info","msg":"\n\nWelcome to Node-RED\n===================\n"}
{"ts":"17054205228380000","level":"info","msg":"Node-RED version: v3.0.2"}
{"ts":"17054205228380001","level":"info","msg":"Node.js  version: v18.19.0"}
{"ts":"17054205228380002","level":"info","msg":"Linux 6.6.6-100.fc38.x86_64 x64 LE"}
{"ts":"17054205231200000","level":"info","msg":"Loading palette nodes"}
{"ts":"17054205237410000","level":"warn","msg":"------------------------------------------------------"}
{"ts":"17054205237420000","level":"warn","msg":"[@flowfuse/nr-file-nodes/file] 'file in' already registered by module node-red"}
{"ts":"17054205237420001","level":"warn","msg":"------------------------------------------------------"}
{"ts":"17054205237420002","level":"info","msg":"Settings file  : /opt/share/projects/flowforge/flowforge-dev-env-new/packages/flowfuse/var/projects/32223823-3e89-467a-a640-2c5deffba0a2/settings.js"}
{"ts":"17054205237430000","level":"info","msg":"Context store  : 'default' [module=memory]"}
{"ts":"17054205237530000","level":"info","msg":"Server now running at http://127.0.0.1:12085/"}
{"ts":"17054205237650000","level":"warn","msg":"Encrypted credentials not found"}
{"ts":"17054205237670000","level":"info","msg":"Starting flows"}
{"ts":"17054205237680000","level":"info","msg":"Started flows"}

As this is already a JSON format it should make ingesting by the log storage system easier than the Node-RED raw text.

hardillb commented 9 months ago

I have code for the above MVP, the outstanding question is where to put the control for this as I feel it should be optional.

Gut feel is that it should be in the template so it can be set for all instances by admins or on a per instance level if left unlocked.

hardillb commented 9 months ago

Rather than add to the template this will be implemented as an option passed to the driver (in the flowforge.yml file) as it feels more like a platform wide thing.

Docs updated and option added to the helm values.yml.

hardillb commented 9 months ago

Will need to be verified on my local k8s or docker install as not going to be enabled on staging/production. Will install and check