Hostname in Couchbase eventing code

Hi Team,
Is there a way to get eventing running hostname inside eventing function(OnUpdate)? we have 3 node cluster and we wanted to send data to our log management system so we would like to see from which node we are sending it.

Thanks.

Hi @nagarajan_subbaraj

Eventing is designed to hide the infrastructure from the user. Thus you don’t know the node, the worker, or the thread that is processing JavaScript the given mutation.

When OnUpdate(doc,meta) is called you do get meta.vb as long as you don’t change your topology and thus the vBucket map is stable you can use meta.vb as an indicator for what node is processing the mutation as it will map into the output of (I think you want to look at “planner_stats”)
curl -XGET http://Administrator:password@localhost:8096/api/v1/stats
to understand how your vBuckets are distributed thus in a stable system you can use meta.vb with a level of indirection.

Obviously we don’t want to run a curl on every mutation so just run that hourly and when needed you can dereference.