Is there a way to get the Target Host configured in a flow variable ? Tried using target.host & target.url but they are not getting populated. Only target.basepath seems to be getting populated which doesn’t have target host in it.
target.url gives you the complete request URL send to to target endpoint and its scope is target request. SO you can populate its value in and after target request flow. Similarly, target.host hives you target host value and its scope is target response. So you can use it in and after target response flow.
I am trying to fetch the target.url variable in JS policy attached at Target Request flow. I am using TargetServer configuration under LoadBalancer and not under
Ok, I think that I’m beginning to see why this can’t be done… assuming that the load balancing decision is made outside of the flow process, there would be no way to know in advance which host would be picked. There are “loadbalancing” variables that we can read, but these are only in scope after the target server has responded. Can anyone confirm this, or point me towards architectural discussion for load balancing?
@stewartritchie , Yes, You are right. Load balancing decision is made by the MP just before it initiates the call to the backend. That’s the reason these variables are not available in target request pipeline. Let’s say, if some logic like serving the request from cache in target request or a conditional step which raises fault on target request and terminates the request then ideally it doesn’t make sense to do this computation of selecting the target server before target request policies execute.
And also, For example, Let’s say you have selected round robin, First request target1 has been selected. For some reason, there is a fault in policy & request has been terminated in target request. If target servers are selected before policy execution then next pick will be target2 even though you haven’t hit the target server. That’s the reason MP executes the load balancing logic just before it hits the target after the target request pipeline has been processed. Same reason why these variables are not available in target request.
however I noticed that the target_url is not populated in the analytics database which is supposed to be executed after the respond already send back to the client ( in the PostClientfFow).