@dchiesa1/Team, i am trying to add a condition under route rule wherein I am routing it to a target if the kvm flag value is enable. Can i put the below condition
<Condition>(private.kvm_ref.value==“enable”)</condition>
if not what is the correct way of mentioning
Thanks!
YES but
<Condition>
with </condition>
. The latter must be capitalized .That was a typing error.
1 of 100 requests to the proxy endpoint has to be routed to target 2 if kvm value is enable
kvm value is “Enable”
<RoutRule name=“Target2”>
<TargetEndpoint>Target2</TargetEndpoint>
<Condition>(private.kvm_ref.value==“enable”)</Condition>
so wanted to check if i can do this.
@dchiesa1 Let me know if any other information is needed for this.
1 of 100 requests to the proxy endpoint has to be routed to target 2 if kvm value is enable
Under some condition, you want to route 99 of 100 requests to target1, and 1 of 100 inbound requests to target2.
The way I would do this:
the RouteRule logic would be like this:
<RouteRule name="conditional-route">
<Condition>kvm_retrieved_value != null AND route_sample = 100</Condition>
<TargetEndpoint>target2</TargetEndpoint>
</RouteRule>
<RouteRule name='default'>
<TargetEndpoint>target1</TargetEndpoint>
</RouteRule>
And the JS to compute the route_sample number is:
<JavaScript name='JS-Compute-Route-Metric'>
<Source>
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var randomNumber = getRandomNumber(1, 100);
context.setVariable('route_sample', randomNumber);
</Source>
</JavaScript>
And of course if you wanted to change the weighting on the routes, you could modify the condition to reference the kvm_retrieved_value.
<RouteRule name="conditional-route">
<Condition>kvm_retrieved_value != null AND route_sample > kvm_retrieved_value</Condition>
<TargetEndpoint>target2</TargetEndpoint>
</RouteRule>
<RouteRule name='default'>
<TargetEndpoint>target1</TargetEndpoint>
</RouteRule>