-
Notifications
You must be signed in to change notification settings - Fork 110
Expression Language
jmxtrans-agent uses an expression language based on property placeholders (e.g. "${graphite.host:2003}
", ObjectName properties (e.g. "%name%
") and basic functions (e.g. "#canonical_hostname#
").
jmxtrans-agent supports property placeholders with the ${prop-name[:default-value]}
syntax.
The default-value
is optional. An exception is raised if no default value is defined and the property placeholder is not found.
Properties are looked-up in the following order:
- If specified by the system property
-Djmxtrans.agent.properties.file=<fileOrUrl>
, properties are looked up in the specified properties file. The properties file follows the format of files thatjava.util.Properties
can load. (supported from version 1.2.3) - JVM system properties (
System.getProperty("graphite.host")
) - JVM environment variables (
System.getenv("graphite.host")
) - JVM environment variables after a "to-upper-case + dot-to-underscore" transformation (
System.getenv("GRAPHITE_HOST")
)
Query resultAlias
support usage of ObjectName properties with the %myproperty%
syntax.
ObjectName property values are escaped with the following rules:
- If a value of a property is escaped with double quotes (see
ObjectName.quote(value)
), the double quotes are removed from the jmxtrans-agent resolved value (e.g. if"mydatasource"
->mydatasource
). - Non alpha-numeric letters are replaced by underscore:
'_'
(e.g.jdbc/my-datasource
->jdbc_my_datasource
).
Sample of ObjectName property usage in query resultAlias
Configuration:
<query objectName="Catalina:type=DataSource,context=/,host=localhost,class=javax.sql.DataSource,name=*"
attribute="numActive" resultAlias="tomcat.datasource.%name%.numActive" />
Will match ObjectName:
Catalina:type=DataSource,context=/,host=localhost,class=javax.sql.DataSource,name="jdbc/my-datasource"
And resultAlias
will be:
tomcat.datasource.jdbc_my_datasource.numActive
jmxtrans-agent supports basic functions with "#
" based expressions like "#my_function#
".
List of out-of-the-box functions:
Function | Description |
---|---|
#hostname# |
Value of InetAddress.getLocalHost().getHostName() |
#reversed_hostname# |
Same as #hostname# in the reverse order (e.g. server1.mycompany.com -> com.mycompany.server1 ) |
#escaped_hostname# |
same as #hostname# with "." replaced by "_" (e.g. server1.mycompany.com -> server1_mycompany_com ) |
#canonical_hostname# |
Value of InetAddress.getLocalHost().getCanonicalHostName() |
#reversed_canonical_hostname# |
same as #canonical_hostname# in the reverse order (e.g. server1.mycompany.com -> com.mycompany.server1 ) |
#escaped_canonical_hostname# |
same as #canonical_hostname# with "." replaced by "_" (e.g. server1.mycompany.com -> server1_mycompany_com ) |
#hostaddress# |
Value of InetAddress.getLocalHost().getHostAddress() |
#escaped_hostaddress# |
same as #hostaddress# with "." replaced by "_" |