Enabling metrics
To enable metrics on your application, add the following settings to your system definition file:
item(name = "MetricsEnabled", value = "true")
item(name = "MetricsReportType", value = "{see below for details}")
item(name = "MetricsClassLoaderStatsEnabled", value = "true")
item(name = "MetricsProcessorStatsEnabled", value = "true")
Property | Default | Explanation |
---|---|---|
MetricsEnabled | false | enables metrics for your application |
MetricsReportType | n/a | a comma-separated list of metrics reporters |
MetricsProcessorStatsEnabled | false | enables additional process metrics |
MetricsClassLoaderStatsEnabled | false | enables additional classloader metrics |
Metric names
The framework provides an abstraction on top of the reporters. A single interface is used, regardless of how the metrics are reported.
Each metric has an identifier that consists of a name and a series of tags.
The framework provides these tags for every metric:
Metric | Explanation |
---|---|
groupName | process group, e.g. GENESIS or AUTH |
processName | the name of the process e.g. GENESIS_ROUTER |
hostname | the hostname e.g. TAM_PROD1 |
In addition to these tags, each metric can provide additional tags. How these tags are reported depends on the metric reporter.
Metric reporters
You can specify multiple reporters. Your list must be comma-separated, e.g. GRAPHITE,DATADOG
.
The reporter affects the name of metrics.
Within the framework, metrics have a name and tags.
The available reporters are:
Reporter | Description |
---|---|
GRAPHITE | Publishes metrics to a Graphite server |
DATADOG | Publishes metrics to a Datadog server |
SLF4J | Publishes metrics to the services' log file |
Graphite
Graphite is an open-source sink that you can use for metrics in Genesis applications.
Graphite is often paired with Grafana, which can source data from Graphite and provides the means to set up and display alerts.
Graphite reports metrics in a hierarchical - tree - structure.
There are two ways for Genesis to generate the metric id for graphite: either hierarchical or dimensional.
Hierarchical metric structure
When the hierarchical structure is used, the metric id will be built of the following components separated by dots .
.
- genesis
- the value of the group name tag
- the value of the process name tag
- the value of the host name tag
- additional tags, including the key and value
- the metric name
e.g. genesis.genesis.genesis_router.tam_prod1.active_connections
Dimensional metric structure
When the dimensional metric structure is used, the metric id will begin with the metric name and all tag keys and values are joined.
e.g. active_connections{hostName=tam_prod1.processName=genesis_router.groupName=genesis}
.
Settings
To support Graphite, the URL and port should be specified in your system definition file:
item(name = "MetricsGraphiteURL", value = "localhost")
item(name = "MetricsGraphitePort", value = "2003")
item(name = "MetricsStructureType", value = "hierarchical")
For the MetricsStructureType
, Genesis metrics supports both hierarchical
and dimensional
.
Datadog
Datadog is a proprietary cloud-based metrics sink that you can use with Genesis.
Datadog supports tags, and these are provided, along with the metric name.
To use Datadog, make the following three settings to your application's system definition file:
item(name = "MetricsDatadogApiKey", value = "YOUR_API_KEY")
item(name = "MetricsDatadogApplicationKey", value = "YOUR_APP_KEY")
item(name = "MetricsDatadogUri", value = "https://api.datadoghq.com")
SLF4J
Metrics can be reported straight to the log file.
This is an easy way to test metrics during development and testing; however, it is not recommended in a production environment.
There are three optional properties for the logger reporter:
item(name = "MetricsReportIntervalSecs", value = "60")
item(name = "Slf4jReporterLoggingLevel", value = "DEBUG")
item(name = "Slf4jReporterLogInactive", value = "true")
Property | Default | Explanation |
---|---|---|
MetricsReportIntervalSecs | 60 | interval between metrics log messages |
Slf4jReporterLoggingLevel | DEBUG | the log level to use |
Slf4jReporterLogInactive | true | when set to true , metrics with a zero 0 will not be reported |