Configuring metrics.xml
Metrics are enabled for all the reporters used by setting the Enabled
parameter under the metrics
element to true
in the <ML_HOME>/resources/conf/metrics.xml
file. If you want to disable metrics for an individual reporter, set the Enabled
 parameter under the relevant reporter element to false
.
If you set the  the Enabled
 parameter under the metrics
 element to false
, metrics will be disabled for all the reporters and it is not possible to enable metrics for individual reporters.
The reporters included by default in the metrics.xml
 file are JMX
, CSV
and JDBC
.
JMX
The parameters that can be configured for JMX are as follows.
Element Name | Description | Type | Default Value | Mandatory/Optional |
---|---|---|---|---|
Enabled | This parameter specifies whether metrics is enabled for JMX or not. | Boolean | true | Mandatory |
CSV
The parameters that can be configured for CSV are as follows.
Element Name | Description | Type | Default Value | Mandatory/Optional |
---|---|---|---|---|
Enabled | This parameter specifies whether metrics is enabled for CSV or not. | Boolean | false | Mandatory |
Location | The location in which the CSV files are stored. | String | <ML_HOME>/repository/logs/metrics/ | Mandatory |
PollingPeriod | The time interval at which the a polling activity is carried out to update the metrics dashboard based on the latest information. e.g., if the polling period is 60 , polling would be carried out every 60 milliseconds. | Integer | 60 | Mandatory |
JDBC
The parameters that can be configured for JDBC are as follows.
Element Name | Description | Type | Default Value | Mandatory/Optional |
---|---|---|---|---|
Enabled | This parameter specifies whether metrics is enabled for JDBC or not. | Boolean | true | Mandatory |
DataSourceName | The name of the datasource used. | String |
jdbc/WSO2MetricsDB
| Mandatory |
PollingPeriod | The time interval at which the a polling activity is carried out to update the metrics dashboard based on the latest information. e.g., if the polling period is 60 , polling would be carried out every 60 milliseconds. This value is specified in milliseconds. | Integer | 60 | Mandatory |
ScheduledCleanup | This element contains parameters relating to the scheduled clean-up which includes Enabled , ScheduledCleanupPeriod and DaysToKeep . Scheduled clean-up involves creating a scheduled task to clear metric data in the database after a specified time interval. This is done to avoid excessive memory usage. | N/A | N/A | Mandatory |
ScheduledCleanup/Enabled | This parameter specifies whether scheduled cleanup is enabled or not. | Boolean | true | Mandatory |
ScheduledCleanup/ScheduledCleanupPeriod | The number of milliseconds that should elapse after a clean-up task before the next clean-up task is carried out. | Integer | 86400 | Mandatory |
ScheduledCleanup/DaysToKeep | The number of days during which the scheduled clean-up task should be run. | Integer | 7 | Mandatory |
Example
The following is an excerpt of the metrics.xml
file.
--> <!-- This is the main configuration file for metrics --> <Metrics xmlns="http://wso2.org/projects/carbon/metrics.xml"> <!-- Enable Metrics --> <Enabled>false</Enabled> <!-- Metrics reporting configurations --> <Reporting> <JMX> <Enabled>true</Enabled> </JMX> <CSV> <Enabled>false</Enabled> <Location>${carbon.home}/repository/logs/metrics/</Location> <!-- Polling Period in seconds --> <PollingPeriod>60</PollingPeriod> </CSV> <JDBC> <Enabled>true</Enabled> <!-- Source of Metrics, which will be used to identify each metric in database --> <!-- Commented to use the hostname <Source>Carbon</Source> --> <!-- JNDI name of the data source to be used by the JDBC Reporter. This data source should be defined in a *-datasources.xml file in conf/datasources directory. --> <DataSourceName>jdbc/WSO2MetricsDB</DataSourceName> <!-- Polling Period in seconds --> <PollingPeriod>60</PollingPeriod> <ScheduledCleanup> <!-- Schedule regular deletion of metrics data older than a set number of days. It is strongly recommended that you enable this job to ensure your metrics tables do not get extremely large. Deleting data older than seven days should be sufficient. --> <Enabled>true</Enabled> <!-- This is the period for each cleanup operation in seconds --> <ScheduledCleanupPeriod>86400</ScheduledCleanupPeriod> <!-- The scheduled job will cleanup all data older than the specified days --> <DaysToKeep>7</DaysToKeep> </ScheduledCleanup> </JDBC> </Reporting> </Metrics>