Version: 17.07
Let it be an Enterprise Service Bus or any other integration product, more often than not it is required to collect metrics and statistics on different aspects of the product. Adroitlogic Project-X caters this requirement by providing built-in metrics collection and publishing capabilities with the flexibility to plugin a metrics engine only if it is required.
Project-X currently provides a metrics engine implementation based on the popular Elasticsearch analytics engine and the user has the freedom to either use an external Elasticsearch server or use the embedded Elasticsearch server of Project-X to collect statistics.
The metrics collector collects all the reported metrics values inside a configurable metrics window and at the end of the metrics window, it calculates an aggregated value for each metrics stream and reports to the metrics publisher. In configurable time intervals, the metrics publisher publishes these reports as a bulk to the underlying statistics server. The algorithm used by the metrics collector to calculate the aggregated value depends on the Record Type of the metrics stream.
Project-X metrics engine currently supports the following metrics record types and based on these types.
Counter |
Counter type should be used for metrics streams that are countable one by one. Metrics streams of this type start with the value 0 and can be either incremented by 1 or decremented by 1 at a time. The final count at the end of metrics window will be considered as the aggregated value and it can be either positive or negative based on the number of increment operations and decrement operations performed.
|
||
Counter Map |
Counter Map type is very much similar to the Counter type, but it can be used to keep several counters under a single metrics stream. Unlike in Counter type where a single value is either incremented or decremented, Counter Map type has set of counters each with a unique key and any one of them can be incremented or decremented independently providing the corresponding key with the increment or decrement operation.
|
||
Summation Gauge |
Gauge type can be used for a metrics streams that reports a different value each time. This reporting value can be either a whole number of a decimal. But it is always assumed that this reported value to be non-negative and any negative values reported for a Gauge type metrics stream will be ignored. In the Summation Gauge, the summation of all the reported values at the end of metrics window will be considered as the aggregated value.
|
||
Average Gauge |
Average Gauge type is very much similar to the Summation Gauge type, except for the fact that the average of all the reported values at the end of metrics window will be considered as the aggregated value.
|
To enable Elasticsearch based metrics, the easiest way is to use an UltraESB-X complete distribution which contains all
the required dependencies and configuration. Extract the distribution to a location of your choice and navigate to the
file conf/server.xml
. In the file, make sure that the following spring import statement is present and it is not in a
commented state.
<import resource="metrics/metrics.xml"/>
All the metrics related configurations of Project-X are enclosed in the conf/metrics/metrics.xml
file. Open that file
and configure the parameters related to Elasticsearch Server, Metrics Publisher, Metrics Collector and Metrics
Engine as follows.
As mentioned before, Project-X provides the capability to either use its embedded Elasticsearch server or to use an external standalone Elasticsearch server to collect statistics. To enable the embedded Elasticsearch server, configure the es-server bean as follows.
<bean id="es-server" class="org.adroitlogic.x.metrics.EmbeddedElasticsearchServer"/>
This embedded Elasticsearch sever uses the configuration file conf/metrics/elasticsearch.yml
and can be fine-tuned by
altering the parameters in that file. Please refer
Elasticsearch Documentation on
these configurations.
If one or more external Elasticsearch servers are being used, es-server bean should be configured as below.
<bean id="es-server" class="org.adroitlogic.x.metrics.ExternalElasticsearchServer">
<constructor-arg>
<map>
<entry key="server1" value="9300"/>
<entry key="server2" value="9300"/>
</map>
</constructor-arg>
<constructor-arg value="es-cluster" type="java.lang.String"/>
</bean>
Property | Description | Default Value |
---|---|---|
Constructor Arguments |
Map with the hostname and connection port of each external Elasticsearch server as key-value pairs |
|
Name of the Elasticsearch cluster |
|
The embedded Elasticsearch server of Project-X is intended only to be used for the development/testing purposes and it is highly recommended to use one or more external Elasticsearch servers in production deployments. |
The Elasticsearch based Metrics Publisher of Project-X can be configured as below.
<bean id="es-publisher" class="org.adroitlogic.x.metrics.ESStatisticsPublisher">
<constructor-arg ref="es-server"/>
<property name="esHealthTimeoutMillis" value="5000"/>
<!--Template & Alias Configuration-->
<property name="templateFile" value="ultraesb-x-template.json"/>
<property name="inactiveSettingFile" value="inactive-index-setting.json"/>
<property name="indexTemplateName" value="ultraesb_x_template"/>
<property name="initialIndexName" value="ultraesb_x-000001"/>
<property name="activeIndexAliasName" value="active_ultraesb_x"/>
<property name="inactiveIndexAliasName" value="inactive_ultraesb_x"/>
<property name="indexMappingType" value="x_statistics"/>
<!--BulkProcessor Configuration-->
<property name="bulkActions" value="1000"/>
<property name="bulkSizeInMB" value="5"/>
<property name="flushIntervalInSeconds" value="60"/>
<property name="concurrentRequests" value="1"/>
<property name="backOffExponentialTimeInMillis" value="100"/>
<property name="backOffExponentialRetryAttempts" value="3"/>
<property name="optimized" value="true"/>
<!--RollOver Configuration-->
<property name="maxDocs" value="1000"/>
<property name="maxAgeInMinutes" value="15"/>
<property name="rollOverTimePeriodInMinutes" value="10"/>
<property name="indexRollOverEnabled" value="true"/>
<property name="deleteOldestIndexAfterRollOver" value="true"/>
<property name="deleteInactiveIndicesAtInit" value="false"/>
<property name="deleteInactiveIndicesAtDestroy" value="false"/>
</bean>
Property | Description | Default Value | ||
---|---|---|---|---|
Constructor Arguments |
Reference to the Elasticsearch Server bean configured in the previous step |
|||
esHealthTimeoutMillis |
Time in milliseconds to wait until Elasticsearch cluster status becomes yellow |
|
||
templateFile |
Name of the JSON file containing the index template which includes the mapping, setting and aliases
|
|
||
inactiveSettingFile |
Name of the JSON file containing the setting which will be set to indices which are rolled over. |
|
||
indexTemplateName |
Name for the index template in the JSON file pointed by templateFile property. |
|
||
initialIndexName |
If an ultraesb index does not exist at the startup, a new index will be created. This property represents that initial index name. |
|
||
activeIndexAliasName |
Elasticsearch aliases are used to separate out active indices and inactive indices. At any point active alias will only point to one index and that index will be used for indexing new documents. Inactive alias points to indices which are rolled over. Inactive indices will only be used for querying. This property represents name for the active index alias. |
|
||
inactiveIndexAliasName |
This property represents name for the inactive index alias. |
|
||
indexMappingType |
Name of the mapping type to be used for statistics publishing |
|
||
bulkActions |
The number of currently added actions to flush a new bulk publishing request. Can be set to |
|
||
bulkSizeInMB |
The size of currently added actions in Mega Bytes to flush a new bulk publishing request. Can be set to |
|
||
flushIntervalInSeconds |
The time interval in seconds to flush bulk publishing requests |
|
||
concurrentRequests |
The number of concurrent bulk publishing requests allowed to be executed. A value of |
|
||
backOffExponentialTimeInMillis |
In case of bulk request failure, the Exponential Backoff Policy will be used to retry the failed request. This property specifies the initial waiting time in milliseconds before the first retry attempt. |
|
||
backOffExponentialRetryAttempts |
In case of bulk request failure, the Exponential Backoff Policy will be used to retry the failed request. This property specifies the maximum number of retry attempts. |
|
||
optimized |
Setting optimized to true will attempt to optimize indexing performance of bulk requests. Basically this will set index refresh internal to -1 and number of index replicas to 0 before each bulk import and revert back to normal values after the bulk operation. For more technical details related to this optimization read Indexing Performance Tips in elasticsearch documentation.
|
|
||
indexRollOverEnabled |
This enabled elasticsearch index roll over which means once any of the given conditions becomes true elasticsearch indexed will be rolled ever and a new index will be created. For more technical details related to this read Roll Over Documentation |
|
||
maxDocs |
This is one of the roll over conditions which represents the number of documents in the index. |
|
||
maxAgeInMinutes |
This is the other condition for elasticsearch rollover. It represents the age of the index in minutes (time elapsed since the index was created). |
|
||
rollOverTimePeriodInMinutes |
Index roll over is done using a timer task which periodically call the roll over API. This property can be used to set the time interval between two roll over calls. |
|
||
deleteOldestIndexAfterRollOver |
When this property is set to true, the oldest rolled over index will be deleted. Say we start with ultraesb_x-000001 and after one rollover cycle we have ultraesb_x-000001 and ultraesb_x-000002. Now when the next rollover cycle completes, which mean once ultraesb_x-000003 is created we deletes the oldest index which is ultraesb_x-000001. |
|
||
deleteInactiveIndicesAtInit |
If this is set to true, we will delete all the indices which are marked with inactive_ultraesb_x alias at es-publisher init. |
|
||
deleteInactiveIndicesAtDestroy |
If this is set to true, we will delete all the indices which are marked with inactive_ultraesb_x alias at es-publisher destroy. |
|
The Elasticsearch based Metrics Collector of Project-X can be configured as below.
<bean id="es-collector" class="org.adroitlogic.x.metrics.ESMetricsCollector">
<constructor-arg ref="es-publisher" />
<property name="primaryMetricsTemplateValidTime" value="20000"/>
<property name="metricsReportGenerationTimePeriod" value="30000"/>
<property name="metricsTemplateSyncTimePeriod" value="20000"/>
<property name="customFields">
<map>
<entry key="key1" value="constant_value"/>
<entry key="key2" value="env:env_var_name"/>
<entry key="key3" value="sys:sys_prop_key"/>
</map>
</property>
</bean>
Property | Description | Default Value |
---|---|---|
Constructor Arguments |
Reference to the Elasticsearch Metrics Publisher bean configured in the previous step |
|
primaryMetricsTemplateValidTime |
The duration in milliseconds within which a primary metrics template is valid from the time of its creation or from the time of its last reset |
|
metricsReportGenerationTimePeriod |
The time interval in milliseconds in which the metrics reports should be generated and send to the Metrics Publisher |
|
metricsTemplateSyncTimePeriod |
The time interval in milliseconds in which the primary and secondary metrics template syncing is performed. |
|
customFields |
This parameter can be specified as a map to include any additional fields in each metrics record. The key of the entry will be the key of the metrics record field. The value of the metrics record field can be either a constant value, an environment variable value or a system property value. To use an environment variable as the value, the value of the map entry should be of the format |
The Elasticsearch based Metrics Engine of Project-X can be configured as below.
<bean id="metrics-engine" class="org.adroitlogic.x.metrics.ESMetricsEngine">
<constructor-arg ref="es-collector"/>
</bean>
Property | Description | Default Value |
---|---|---|
Constructor Arguments |
Reference to the Elasticsearch Metrics Collector bean configured in the previous step |
The following are the built-in metrics streams of Project-X and they will be reported automatically when metrics are enabled.
Category | Stream Name | Record Type | Description | |
---|---|---|---|---|
System Information |
cpuUsageGauge |
Average Gauge |
Average CPU utilization of the instance as a value out of 100 |
|
usedMemoryGauge |
Average Gauge |
Heap memory utilization in bytes |
||
usedMemoryPercentageGauge |
Average Gauge |
Heap memory utilization as a percentage of maximum available heap memory |
||
activeThreadsGauge |
Average Gauge |
Average number of live threads including both daemon and non-daemon threads |
||
openFDGauge |
Average Gauge |
Average number of open file descriptors |
||
Scale-First Executor Service Metrics |
activeThreadCount |
Average Gauge |
Average number of threads that are actively executing tasks |
|
currentPoolSize |
Average Gauge |
Average number of threads in the pool |
||
currentQueueLength |
Average Gauge |
Average length of the task queue |
||
Integration Flow Metrics |
executionSuccess |
Counter |
Number of successfully completed message flows |
|
executionFailed |
Counter |
Number of failed messages flows |
||
Ingress Connector Metrics |
receivedMsgCount |
Counter |
Number of messages received by the ingress connector |
|
receivedMsgSize |
Summation Gauge |
Total size of the messages received by the ingress connector |
||
sentMsgCount |
Counter |
Number of messages sent by the ingress connector as responses
|
||
sentMsgSize |
Summation Gauge |
Total size of the messages sent by the ingress connector as responses
|
||
Egress Connector Metrics |
sentMsgCount |
Counter |
Number of messages sent by the egress connector |
|
sentMsgSize |
Summation Gauge |
Total size of the messages sent by the egress connector |
||
receivedMsgCount |
Counter |
Number of messages received by the egress connector as responses
|
||
receivedMsgSize |
Summation Gauge |
Total size of the messages received by the egress connector as responses
|
||
sendingSuccess |
Counter |
Number of successfully sent out messages |
||
sendingFailed |
Counter |
Number of sending failed messages |