KV Settings in Policy Issue

Not applicable

Hello,

We're trying to virtualize settings for our Splunk endpoint {splunkEndpointPort}, and when we try to save the following policy, it throws an error. The code is:

<MessageLogging name="commonLogToSplunk">
  <Syslog>
    <Message>{organization.name}.{apiproxy.name}.{environment.name}: {lastLogJSON}</Message>
    <Host>{splunkEndpointUrl}</Host>
    <Port>{splunkEndpointPort}</Port>
    <Protocol>TCP</Protocol>
    <SSLInfo>
        <Enabled>true</Enabled>
    </SSLInfo>
  </Syslog>
</MessageLogging>

The error is:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.795 s
[INFO] Finished at: 2016-03-08T14:06:24-08:00
[INFO] Final Memory: 16M/232M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-ma                                  ven-plugin:1.0.0:deploy (default-cli) on project fault-testing: MojoExecutionExc                                  eption: 400 Bad Request
[ERROR] {
[ERROR] "code" : "rest.ValidationFailure",
[ERROR] "message" : "Error occurred while validation of bean commonLogToSplunk.x                                  ml. Reason: - Schema validation failed. Cause : Not a number: {splunkEndpointPor                                  t}. Line number : 5. Column number : 38. File name : commonLogToSplunk.xml..",
[ERROR] "contexts" : [ ]
[ERROR] }
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit                                  ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea                                  d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE                                  xception

I know the issue is the <Port> element is expecting a number, but if we want to virtualize this setting, it presents an issue with the XML validation it seems. Is there a work-around to circumvent the validation for this policy, or somehow cast this value to a number?

Thanks in Advance, Steve

1 5 480
5 REPLIES 5

I think that configuration is not enabled for "dynamic" resolution at runtime.

If it is possible, you may be able to resolve that information at the time the API proxy gets deployed. If that is not satisfactory, then we'd need to ask for a change in capability.

This is kind of inconsistent. Is there an implementation reason why such variables cannot be available at this point in time?

Not applicable

Hi Dino,

So if I understand you correctly, we would need to have several <MessageLogging> policies with our different configurations for Splunk hostnames/ports, and then Mickey Mouse which one gets called by virtue of a <Condition> element, correct?

Thanks! Steve

That is the correct answer Stephen. Ref tags would be helpful here.

Not applicable

Typically you will use a ref attribute in the tag for dynamic insertion of a variable value for these types of attributes, providing the default value within the tag.

Per documentation refs are not supported for host and port in the MessageLogging policy. You will have to create separate policies for each potential syslog server then conditionally execute those policies in your post flow.

@Stephan.Cossette - this is modeled elsewhere at your client. I can provide pointers to the implementation that is consistent with deploy policies one on one.