Package org.jmxtrans.agent
Class ResultNameStrategyImpl
java.lang.Object
org.jmxtrans.agent.ResultNameStrategyImpl
- All Implemented Interfaces:
ResultNameStrategy
public class ResultNameStrategyImpl extends Object implements ResultNameStrategy
Build a QueryResult.name from a collected metric (Query).
Build name must be escaped to be compatible with all OutputWriter.
The approach is to escape non alpha-numeric chars.
Expressions support '#' based keywords (e.g.
#hostname#) and with '%' based variables mapped to objectname properties.
Supported '#' based 'functions':
| Function | Description | Sample |
|---|---|---|
#hostname# |
localhost - hostname InetAddress.getHostName() |
|
#reversed_hostname# |
reversed localhost - hostname InetAddress.getHostName() |
|
#escaped_hostname# |
localhost - hostname InetAddress.getHostName() with '.' replaced by '_' |
|
#canonical_hostname# |
localhost - canonical hostname InetAddress.getCanonicalHostName() |
server1.ecommerce.mycompany.com |
#reversed_canonical_hostname# |
reversed localhost - canonical hostname InetAddress.getCanonicalHostName() |
com.mycompany.ecommerce.server1 |
#escaped_canonical_hostname# |
localhost - canonical hostname InetAddress.getCanonicalHostName() with '.' replaced by '_' |
server1_ecommerce_mycompany_com |
#hostaddress# |
localhost - hostaddress InetAddress.getHostAddress() |
|
#escaped_hostname# |
localhost - hostaddress InetAddress.getHostAddress() with '.' replaced by '_' |
- Author:
- Cyrille Le Clerc
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ResultNameStrategyImpl()Create with default expression language engine.ResultNameStrategyImpl(ExpressionLanguageEngine expressionLanguageEngine) -
Method Summary
Modifier and Type Method Description protected StringescapeObjectName(ObjectName objectName)Transforms an ObjectName into a plain String only composed of ('a' to 'Z', 'A' to 'Z', '_').ExpressionLanguageEnginegetExpressionLanguageEngine()StringgetResultName(Query query, ObjectName objectName, String attribute, String compositeDataKey, Integer position)voidpostConstruct(Map<String,String> settings)voidsetExpressionLanguageEngine(ExpressionLanguageEngine expressionLanguageEngine)
-
Field Details
-
logger
-
-
Constructor Details
-
ResultNameStrategyImpl
public ResultNameStrategyImpl()Create with default expression language engine. -
ResultNameStrategyImpl
-
-
Method Details
-
getResultName
@Nonnull public String getResultName(@Nonnull Query query, @Nonnull ObjectName objectName, @Nonnull String attribute, @Nullable String compositeDataKey, @Nullable Integer position)- Specified by:
getResultNamein interfaceResultNameStrategy
-
escapeObjectName
Transforms an ObjectName into a plain String only composed of ('a' to 'Z', 'A' to 'Z', '_'). '_' is the escape char for not compliant chars. -
getExpressionLanguageEngine
-
setExpressionLanguageEngine
-
postConstruct
- Specified by:
postConstructin interfaceResultNameStrategy
-