Contact Us 1-800-596-4880

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.

This connector is available only if your organization has the Anypoint Integration Advanced package or a Titanium subscription to Anypoint Platform. For more information, see the Pricing and Packaging documentation.

Prerequisites

Use the following Mule runtime engine versions with Anypoint Monitoring:

  • Mule 3 versions 3.8.7 and later
    Versions 3.8.6 and earlier are not supported. Additionally, all runtime versions that have the -AM suffix are deprecated.
    Inbound and outbound metrics are unavailable for hybrid proxy apps that use Mule runtime engine version 3.9.5 or earlier.

  • Mule 4
    To use enhanced metrics for API Analytics, use Mule runtime engine version 4.1.6 or later.

Custom Metrics Best Practices

Best practices include using time period and frequency effectively as well as using data with low cardinality dimensions.

Use Time Period and Frequency Effectively

Each chart in the Custom Metrics dashboard represents the output of a query. Two parameters in the dashboard, time range and refresh frequency, affect the response time for the query that generates a chart.

Time range

Determines how much data is fetched or processed to generate the chart. For example, more data is fetched and processed when displaying a monthly chart compared to displaying a daily chart.

Refresh frequency

Determines how often a chart refreshes. High refresh frequencies put more stress on a system and can affect performance. For example, a refresh rate of one hour sends a query every hour, and a refresh rate of one minute sends the same query every minute.

Increasing time range (such as daily to monthly) or increasing refresh frequency (from one hour to one minute) affects the system response time. Reduce time range or reduce the refresh frequency to improve the chart response time.

Use Low Cardinality Dimensions

Most custom metric dimensions have less than 100 possible unique values, but some may have a thousand unique values, such as country_code, state_code, city_code, and zip. Do not add high cardinality data, or data with many unique values, to custom metrics. Some examples of high cardinality dimensions include customer_id, user_id, session_id, order_id, transaction_id, email_address, token_id, product_id, location_id (latitude/longitude), ip_address, and phone_number. Charts configured for custom metrics with high cardinality dimensions can adversely affect the response time of dashboards. For best results, restrict dimensions to have only a few unique values.

If a particular custom metrics chart slows down and affects other charts in the system, you can:

  • Create a new custom metric without the offending high cardinality dimension

  • Replace a high cardinality dimension with a low cardinality dimension, such as:

    • category_id instead of product_id

    • country_code instead of location_id

    • order_count instead of order_id

  • Avoid using UUIDs and timestamps when creating new custom metrics

  • Reduce the time range of the custom metric chart, for example, create a daily or weekly chart instead of a monthly or yearly chart

  • Reduce the refresh frequency, for example, refresh hourly instead of every minute.

Restricted Keywords

Due to internal database restrictions, you cannot use the following keywords to define dimensionName or factName while using the Anypoint Custom Metrics connector:

  • ALL

  • ALTER

  • ANALYZE

  • ANY

  • AS

  • ASC

  • BEGIN

  • BY

  • CREATE

  • CONTINUOUS

  • DATABASE

  • DATABASES

  • DEFAULT

  • DELETE

  • DESC

  • DESTINATIONS

  • DIAGNOSTICS

  • DISTINCT

  • DROP

  • DURATION

  • END

  • EVERY

  • EXPLAIN

  • FIELD

  • FOR

  • FROM

  • GRANT

  • GRANTS

  • GROUP

  • GROUPS

  • IN

  • INF

  • INSERT

  • INTO

  • KEY

  • KEYS

  • KILL

  • LIMIT

  • SHOW

  • MEASUREMENT

  • MEASUREMENTS

  • NAME

  • OFFSET

  • ON

  • ORDER

  • PASSWORD

  • POLICY

  • POLICIES

  • PRIVILEGES

  • QUERIES

  • QUERY

  • READ

  • REPLICATION

  • RESAMPLE

  • RETENTION

  • REVOKE

  • SELECT

  • SERIES

  • SET

  • SHARD

  • SHARDS

  • SLIMIT

  • SOFFSET

  • STATS

  • SUBSCRIPTION

  • SUBSCRIPTIONS

  • TAG

  • TO

  • USER

  • USERS

  • VALUES

  • WHERE

  • WITH

  • WRITE

  • TIME

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.

    Custom Metrics Connector requires all Facts to be sent from every operation, even if they contain empty or 0 value in them.

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.