https://learn.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics
About capturing custom variables using query than show a result on dashboard (Nodejs-javascript) ?
If you're asking how do you capture those metrics and events from a nodejs application, this article should give you the answers you need:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/nodejs.
If you have tried this and can't get it to work, please add additional details to your question and I can expand this answer.