Home > Software design >  Get a unique identifier of the current instance within typescript code for the multi-instance node j
Get a unique identifier of the current instance within typescript code for the multi-instance node j

Time:07-05

We are using a node js application along with Kubernetes with auto-scaling. My requirement is to log a few things wrt the current instance (pod, IP or anything unique for that instance).

Is there any way in the node js and typescript to get such identifiers in the backend application?

CodePudding user response:

The hostname will contain the unique (per namespace) pod name. So just get the current hostname of the backend and you have a unique identifier.

For example

const os = require("os");

const hostName = os.hostname();
  • Related