The Java Extension SDK provides an automated utility that allows extensions developers to transform a metric name and value as it would be represented in the Metric Browser. These transformers include the following:
In the metrics.xml
, the transformers should be specified in the following manner.
<stat url="/nitro/v1/stat/lbvserver" rootElement="lbvserver" alias="Load Balancing Server Metrics"> <metric attr="cursrvrconnections" alias="Server Connections"/> <metric attr="memoryInMBytes" alias="Memory in KB" multiplier="1000"/> <metric attr="throughput" delta="true" /> <metric attr="state"> <convert str="DOWN" value="0"/> <convert str="UP" value="1"/> <convert str="UNKNOWN" value="2"/> </metric> </stat>
In the config.yml
, the transformers should be specified in the following manner.
metrics: - name: “cursrvrconnections” alias: “Cursor RV Connections” delta: true multiplier: 1000 convert: “DOWN”: 0 “UP”: 1 “UNKNOWN”: 2
Note that multiple transformers can be applied to the same metric as follows:
<metric attr="cursrvrconnections" alias="Server Connections" multiplier="10" delta="true"/>
Please note the following:
On calling transformAndPrintMetrics(List<Metric> metrics)
in com.appdynamics.extensions.MetricWriteHelper
, the SDK automatically applies any configured transformers before publishing these metrics.
The Alias transformer can be used to replace a metric’s name. Often, metrics are represented by ambiguous names in the artifacts being monitored, as evident in the example above. In this case, cursrvrconnections will be represented as Server Connections in the Metric Browser.
The Multiplier transformer can be used to multiply the original metric value by a configured factor. From the example above, consider that an artifact returns memory in MB and a requirement is to monitor this metric in KB. A multiplier of 1000 can be applied to this metric to satisfy this requirement.
Consider an ever-increasing metric value and a requirement is to monitor the number of units by which this metric increases every minute. A Delta transformer can be applied in this case. This transformer compares the value of a metric at minute X with its value at minute X-1 and publishes the difference as a metric value.
Note: Everytime the extension is run, the first value will not be reported if delta is true.
The Convert transformer can be applied to metrics that return a text value from an artifact’s API. These text values can be represented as numeric values. From the example above, DOWN will be represented with a value of 0, UP with 1 and UNKNOWN with 2 for the state metric.