Contact Free trial Login

Custom Metrics

The Anypoint Custom Metrics connector enables you to send operational and business metric values that you define from an app to Anypoint Monitoring. You can then use the built-in Custom metrics dashboard and a custom dashboard in Advanced mode to visualize the custom metrics in real time.

Define metrics in the Anypoint Custom Metrics connector to select which metrics to display in the dashboard. You can filter and group the metrics along the dimensions you define to include multiple custom and built-in metrics in a single dashboard visualization.

The Custom Metrics connector is available for both Mule 3 and Mule 4 in the Monitoring > Custom Metrics page.

To see the metrics you configure in the Anypoint Custom Metrics connector in Anypoint Monitoring, you must have a Titanium subscription.

Prerequisites

Use Design Center to Configure the Custom Metrics Values

Create a Mule application project in Design Center and configure the Custom Metrics connector.

  1. In Design Center, create a new Mule application project.
    The project opens in Design Center.

  2. Select the trigger for your flow, and click Next.

  3. For Target, select Anypoint Custom Metrics Connector, and click Done.

    custom metric dc select target

    The connector has one operation called Send Custom Metric.

  4. On the design canvas, open the Anypoint Custom Metrics Connector card to add your metrics.

  5. In Metric Name, enter a meaningful value.

  6. Next to Dimensions, click Add to enter the name and value for the metric’s dimension.

    custom metric dc add dimension
    1. In the Add Item dialog box, enter the Dimension Name and Value for the dimension.

    2. Leave the Collapsible option with the default of True.

    3. Click OK.

      custom metric dc add item

      You can repeat these steps to add multiple key values.

  7. Next to Facts, click Add to add facts for the metric. Values for measurements are always numerical.

    1. In the Add Item dialog box, enter a Fact Name and numerical Value for the fact.

      For facts, the value must always be numerical. This is not validated at design time, but a non-numerical value will cause a runtime exception once deployed.
      custom metrics add fact
    2. Click OK.
      You can repeat these steps to add multiple key values.

  8. Select the Throw Runtime Exception on Validation Failure option if you want the flow to break if invalid values are entered for the metric. If this option is left unchecked, an error will be logged, but the flow won’t break.

Configure Custom Metrics Values Using Anypoint Studio

  1. Search Anypoint Exchange for the Anypoint Custom Metrics connector.

  2. Drag the Send Custom Metric operation to the canvas.

  3. Add the Send Custom Metric operation to your application flow.
    This image shows an example flow for custom metrics in Anypoint Studio.

    custom metric example flow
  4. Click the Send Custom Metric operation to add values for the operation.

  5. Add the dimension for the metric:

    1. In Metric name, enter a meaningful value, for example "sales."

    2. In Enter contextual information select Edit inline to enter the name and value for the dimension.

    3. Click the green plus on the left to enter the values.

    4. In the Dimension dialog box, enter the Name and Value for the dimension.

    5. Leave the Collapsible option with the default of True.

    6. Click Finish.
      You can repeat these steps to add multiple key values.

  6. Enter the facts for the metric. Values for measurements are numerical.

    1. In Enter measurements select Edit inline to enter the name and value for the metric.

    2. In the Fact dialog box, enter a Name and numerical Value for the fact.

      For facts, the value must always be numerical. This is not validated at design time, but a non-numerical value will cause a runtime exception once deployed.
    3. Leave the Collapsible option with the default of True.

    4. Click Finish.
      You can repeat these steps to add multiple key values.
      This image shows example values for a custom metric that tracks t-shirt sales.

      custom metrics connector config
  7. Select the Throw runtime exception on validation failure option if you want the flow to break if invalid values are entered for the metric. If this option is left unchecked, an error is will be logged, but the flow won’t break.

Deploy the Application

  1. Deploy the app.

  2. In Anypoint Monitoring, add a new custom dashboard for the custom metric.
    This image shows an example of the configuration for a graph to display t-shirt sales.

    custom metric custom dashboard config
    You only see the custom metrics in the pre-populated metric selection drop-down lists once something is logged for the custom metric.
    custom metric custom dashboard graph

Use the Custom Metrics Dashboard

Custom metrics are not collected for the app until you configure the Custom Metrics Connector in your application flow and deploy the application to a server or server cluster.

  1. In Anypoint Monitoring, select the application to view metrics for, and click View.

  2. Click the Custom metrics tab.

    If the Custom Metrics connector has collected one or more metrics in the specified time range, one chart per defined metric is displayed.
    custom metrics dashboard
  3. Click Select a measurement for this chart to display the measurement for the chart.

  4. Use the drop-down lists at the bottom of the chart to filter the data by:

    • Aggregation - Possible aggregations include:

      • None (default) - No data aggregation.

      • count - Displays the total number of items collected for the measurement.

      • distinct - Returns the unique values for the given measurement.

      • integral - Returns the area under the curve for subsequent values.

      • mean - Returns the arithmetic average of the specified measurement over a given interval of time.

      • median - Displays the middle value for the collected metrics.

      • mode - Displays the most frequent value in the metrics collected for the defined measurement.

      • sum - Displays the sum of all the values for the defined measurement.

    • Measurement - The choices in this list are determined by the measurement values you define in the Custom Metrics connector.

    • Group by - The choices in this list are determined by the values you define in the Custom Metrics connector.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub