Knowledge Base

cancel
Showing results for 
Search instead for 
Did you mean: 

Metric Path CharSequence Replacements in Extensions

Table of Contents

Use Case

Configuration

 

Use case

The AppDynamics Controller currently supports only ASCII characters in the metric path. There are several reserved characters that are not supported and can cause undesirable behavior if present in the metric path.

 

The characters separated by "|" in the metric path are called tokens. The Metric Char Replacement can be used on all metric paths that belong to any of the following scenarios :

  • The tokens have characters outside ASCII range (unicode characters)
  • The tokens have some reserved characters
  • The user wants to replace some text across all tokens with shorter or more meaningful text

 

These are things to consider when forming a metric path:

  • Non-ASCII characters are not allowed.
  • The default metric separator for any metric is “|” and an occurrence of “|” creates a new level of hierarchy in the metric tree. Therefore, unless “|” is actually meant for creating hierarchies, it should not be part of a metric token.
  • “:” is similar to “|” in that it will create a new hierarchy.
  • “,” is a special character and cannot be used in the metric path.

 

Configuration

In order to use the Metric Char Replacement feature of the Java SDK for AppDynamics Extensions, the following section must be included in your config.yml:

 

metricPathReplacements:
  - replace:
    replaceWith:

 

Note:

  • The “replace” value cannot be empty.
  • The “replaceWith” value cannot contain non-ASCII characters or “|”, “,”, “:”.

 

Example: 

 

metricPathReplacements:
  - replace: "&"
    replaceWith: ""
  - replace: "-"
    replaceWith: "_"

 

The example here configures two replacements: replace “&” with “” and replace “-” with “_”. If a metric has tokens like “Read&Write”, it will get converted to “ReadWrite” and tokens like “wait-time” will get converted to “wait_time”.

 

The metric replacement module also loads some default replacements:

  •  “|”, “,”, “:” are replaced with “” (empty string).
  • These default values can be overridden by configuring them in your config.yml to be replaced with another character.

 

For Metric Char Replacement to work correctly, the path should not be formed in the extension’s code. Rather, the extensions commons library methods should be used to form the metric path. There are two ways to do this:

  1. Directly use the Metric constructor with signature.
    public Metric(String metricName, String metricValue, Map<String, ?> metricProperties, String metricPrefix, String... tokens)
  2. Use MetricPathUtils.buildMetricPath(String metricPrefix, String... metricTokens) to first build the metric path and then create the Metric object using the Metric constructor that accepts the metric path created earlier.
Version history
Revision #:
4 of 4
Last update:
‎01-22-2019 01:35 PM
Updated by:
 
Labels (1)
Tags (1)
0 Kudos