Wso2 H2 MetricsDB

Wso2 uses MetricsDB to monitor the useful metrics in wso2 servers. The data stored in the MetricsDB are not critical for the server functionality but the data is very important to analyze the server performance when there is an issue. We can see the metrics and get an idea how the server behaved.

Enabling Metrics

 The metrics feature can be enabled from $CARBON_HOME/repository/conf/metrics.xml by making <Enabled>true</Enabled>. Also we can, use -Dmetrics.enabled=true at the server start up to enable Metrics feature without editing the metrics.xml configuration file.

View the Metrics DB in default h2

1. Uncomment the following lines in wso2 carbon.xml located in {Carbon_Home}/repository/conf.
    <H2DatabaseConfiguration>
        <property name="web" />
        <property name="webPort">8082</property>
        <property name="webAllowOthers" />
    </H2DatabaseConfiguration>
2. Restart the server
3. Access http://localhost:8082 using the browser.
4.Provide JDBC URL : jdbc:h2:repository/database/WSO2MetricsDB
                User Name: wso2carbon
                Password   : wso2carbon and connect to the database.
5.You can see five tables in the database as
       METRIC_COUNTER
       METRIC_GAUGE
       METRIC_HISTOGRAM
       METRIC_METER
       METRIC_TIMER


There are five types of metrics as below which are store in above tables.
  • Counter
  • Gauge
  • Histogram
  • Meter
  • Timer
There are five tables(mentioned above) for each metric type. The Carbon Metrics feature store data from each metric in this database. There is a JDBC Reporter running each one minute to store data in this database. The polling period can be configured from repository/conf/metrics.xml. There is also a clean up task to remove data older than 7 days. The ultimate purpose of monitoring these statistics is to get an idea about server performance.

Instead of the h2 database wso2 recommends to use a central database to store the metrics.

Move metrics DB to a centralized MySQL DB

Please use following steps to move metrics DB to a centralized MySQL DB.
  • Comment the h2 related datasource details from metrics-datasources.xml located in {IS_HOME}/repository/conf/datasources.
  • Uncomment MySQL related datasource from metrics-datasources.xml.
  • Create a database wso2_metrics in Mysql.
  • Provide the username and password in MySQL datasource accordingly.
  • Once you startup the server you can see the five tables have been created inside the wso2_metrics database in MySQL.
 

Comments

Popular posts from this blog

Applying CORS Filter to wso2 Identity Server

JWKS endpoint of wso2 IS

DCR VS DCRM with WSO2 Identity server