Dynamic value for header in the request sent by Health Monitor for Target Server

Hi

Is there any variable(dynamical value) available in the targetEndPoint specification which can be used so that the header value(TraceId) sent for every request to target servers by the health monitor in load balancer differs.

I am not sure to use {messageId} as there is no request posted by the client and the request is generated by the health monitor in load balancer itself.

Regards,

Venkat

1 6 535
6 REPLIES 6

I understand your question.

Unfortunately, I think the answer is no.

Currently there is no way to configure the health monitor to insert a dynamic value into a request header. Here's an example configuration:

<HealthMonitor>
  <IsEnabled>true</IsEnabled>
  <IntervalInSec>5</IntervalInSec>
  <HTTPMonitor>
    <Request>
      <ConnectTimeoutInSec>10</ConnectTimeoutInSec>
      <SocketReadTimeoutInSec>30</SocketReadTimeoutInSec>
      <Port>80</Port>
      <Verb>GET</Verb>
      <Path>/healthcheck</Path>
      <Header name="Authorization">Basic 12e98yfw87etf</Header>
    </Request>
    <SuccessResponse>
      <ResponseCode>200</ResponseCode>
      <Header name=”ImOK”>YourOK</Header>
    </SuccessResponse>
  </HTTPMonitor>
</HealthMonitor>

None of those fields is treated as a MessageTemplate; there is no dynamic value that is computed. They are all static.

With the addition of additional various functions to the Message Template , if the header field DID act as a message template, then it would be possible to insert a dynamic header, with something like this:

<HealthMonitor>
  ...
  <HTTPMonitor>
    <Request>
      ...
      <Verb>GET</Verb>
      <Path>/healthcheck</Path>
      <Header name="TraceID">{createUuid()}</Header>
    </Request>
    ...

...but that behavior is not supported.

We can take it as an enhancement request.

In the meantime, I don't know of a good solution. Can you tell me more about why the requests need to be unique?

Thanks for your repsone. We wanted a unique traceId header every time the healthmonitor checks the targetserver health, just to make sure that our back tracking is right.

Hi, we definitely have a requirement for this. Our backend requires a header to be set from environment variables. It would be preferable not to hard-code them into the health check.

Hmmm. Thinking about this further, I see one problem: the message context is independent of any health monitoring.

Considering that, how would we get environment variables into the health monitor? It is possible for the HTTP Monitor to produce a dynamic value for each request, maybe based on the timestamp, the org and environment, and maybe some other things. But ... how would that monitor get other variables?

As an option, maybe lessening the fragility of "hard coding" , you could use the maven deployment plugin which uses a templating approach to inject values into specific configuration files, including the TargetEndpoints, related to each deployment environment.

ref b/152874572