Skip to main content

can someone show an example of a Anypoint Custom Metric Send payload?  I have the following for 'inline,' but can not see to use an expression to do the same.  I'd like to make my dimensions much more dynamic so that I don't have to run a development cycle to update. 

 

this is the xml for the inline option, all other dialogs like this all you to dynamically build the 'payload' for the connector, not sure how to do this...notably for the dimensions 

 

 <custom-metrics:send doc:name=

"Send Custom Metric" doc:id="b4f40e62-4f44-40bc-9ae3-db73cac5e00a" metricName="oneTwo">

 <custom-metrics:dimensions >

 <custom-metrics:dimension dimensionName="aDimension" value=" #payload" />

 </custom-metrics:dimensions>

 <custom-metrics:facts>

 <custom-metrics:fact factName="aCount" value="1" />

 </custom-metrics:facts>

 </custom-metrics:send> 

3 answers
  1. Aug 19, 2025, 1:35 AM

    XML schema does not permit the use of a <ee:foreach> element directly within the <custom-metrics:dimensions> and <custom-metrics:facts> blocks. 

     

    <flow name="dynamic-custom-metrics-flow"> 

        <ee:transform doc:name="Set Dynamic Dimensions and Facts"> 

            <ee:variables> 

                <ee:set-variable variableName="dynamicDimensions"><![CDATA[%dw 2.0 

    output application/java 

    --- 

        "region": "emea", 

        "department": "sales" 

    }]]></ee:set-variable> 

                <ee:set-variable variableName="dynamicFacts"><![CDATA[%dw 2.0 

    output application/java 

    --- 

        "orderCount": 1, 

        "totalValue": 150.75 

    }]]></ee:set-variable> 

            </ee:variables> 

        </ee:transform> 

     

        <custom-metrics:send 

            doc:name="Send Custom Metric" 

            metricName="oneTwo" 

            dimensions="

    #vars.dynamicDimensions mapObject ((value, key, index) -> {dimensionName: key, value: value})

            facts="

    #vars.dynamicFacts mapObject ((value, key, index) -> {factName: key, value: value})

    "> 

        </custom-metrics:send> 

    </flow> 

     

0/9000