Package com.wavefront.common
Class MetricMangler
- java.lang.Object
-
- com.wavefront.common.MetricMangler
-
public class MetricMangler extends Object
Handles updating the metric and source names by extracting components from the metric name. There are several options considered:- source name:
- extracted from one or more components of the metric name (where each component is separated by a '.')
- allow characters to be optionally replaced in the components extracted as source name with '.'
- metric name:
- remove components (in addition to the source name) (this allows things like 'hosts.sjc1234.cpu.loadavg.1m' to get changed to cpu.loadavg.1m after extracting sjc1234)
- Author:
- Mike McLaughlin (mike@wavefront.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetricMangler.MetricComponentsSimple struct to store and return the source, annotations and the updated metric.
-
Constructor Summary
Constructors Constructor Description MetricMangler(String sourceFields, String delimiters, String removeFields)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MetricMangler.MetricComponentsextractComponents(String metric)Extracts the source from the metric name and returns the new metric name and the source name.
-
-
-
Constructor Detail
-
MetricMangler
public MetricMangler(@Nullable String sourceFields, @Nullable String delimiters, @Nullable String removeFields)
Constructor.- Parameters:
sourceFields- comma separated field index(es) (1-based) where the source name will be extracteddelimiters- characters to be interpreted as dotsremoveFields- comma separated field index(es) (1-based) of fields to remove from the metric name- Throws:
IllegalArgumentException- when one of the field index is <= 0
-
-
Method Detail
-
extractComponents
public MetricMangler.MetricComponents extractComponents(String metric)
Extracts the source from the metric name and returns the new metric name and the source name.- Parameters:
metric- the metric name- Returns:
- the updated metric name and the extracted source
- Throws:
IllegalArgumentException- when the number of segments (split on '.') is less than the maximum source component index
-
-