IP address and port of Message Processor

Not applicable

Vodafone has requirement to capture and log the IP address and Port of Message Processor executing the request. My understanding is such information is not available at run-time. Instead, "system.uuid" identifying the message-processor is available. As ZooKeeper has detail of the uuid; IP address can be obtained. At run-time; invoking this call is not recommended, or, storing this mapping at Edge (KVM, etc.) may not be recommended due to maintenance point of view. KVM need to be updated with every re-start of a MP. Is IP address available as part of any attribute, header, etc? Is there any other alternative?

Solved Solved
1 4 647
2 ACCEPTED SOLUTIONS

Not applicable

Our variables page (http://apigee.com/docs/api-services/reference/variables-reference) lists what is available. You would be interested in the system.interface variable. However, our Message Processors have multiple NICs (eth0, eth1, etc). So, if you chose the wrong interface you would not get the IP of where the message was sent.

View solution in original post

dey_santanu
Participant II

From the node module in a proxy you can get the hostname of an MP like below

var os = require("os");  
     res.send(os.hostname());

Then you can use apigee-access node module to set a variable :

apigee.setVariable(request, "custom.foo", "Bar");

View solution in original post

4 REPLIES 4

Not applicable

I don't believe there is any out of the box way to do this but I'll check with Engineering as there may be something new and not yet documented.

Not applicable

Our variables page (http://apigee.com/docs/api-services/reference/variables-reference) lists what is available. You would be interested in the system.interface variable. However, our Message Processors have multiple NICs (eth0, eth1, etc). So, if you chose the wrong interface you would not get the IP of where the message was sent.

dey_santanu
Participant II

From the node module in a proxy you can get the hostname of an MP like below

var os = require("os");  
     res.send(os.hostname());

Then you can use apigee-access node module to set a variable :

apigee.setVariable(request, "custom.foo", "Bar");

g-gagan1000
Participant III

Both the solutions given above works, but our requirement was to get the message processor IP in the shared flow, so node was not the option. For other solution by @Michael Malloy, it is possible to get the IP using "system.interface.{interfaceName}" but the issue is as we will move the API proxy through multiple environments, it is not guaranteed that interface in prod will remain same as of dev or uat.

So we got the IP of message processor using java callout by simple java command given below:

InetAddress.getLocalHost().getHostAddress());

Does anyone else have a better way of doing this?