Metric Module
-
In this project, we provide interface and two implementations
- metrics-interface
- dropwizard metric
- micrometer metric
-
In each implementation, you can use several types of reporter to report metric
- Jmx Reporter
- Prometheus Reporter
- IoTDB Reporter
The acquisition system consists of following four parts.
- Metrics:Provide tools for collecting metric in different scenarios, including Counter, Gauge, Histogram, Timer and Rate, each with tags.
- MetricManager
- Provide functions such as create, query, update and remove metrics.
- Provide its own start and stop methods.
- CompositeReporter
- Provide management of reporter.
- Provide metric value to other systems, such as Jmx, Prometheus, IoTDB, etc.
- Provide its own start and stop methods.
- MetricService
- Provide the start and stop method of metric service.
- Provide the ability to reload properties when running.
- Provide the ability to load metric sets.
- Provide the access of metricManager and CompositeReporter.
We implemented the monitoring framework using Dropwizard and Micrometer respectively, and tested the results as follows:
- Processor:Inter(R) Core(TM) i7-1065G7 CPU
- RAM: 32G
- We use a single thread to create counter and run the test cases separately in two frameworks of Micrometer and Dropwizard. The test metrics as follows:
- memory : Memory usage in MB.
- create : The time required to create, in ms.
- searchInorder : The time required for the sequential query, in ms.
- searchDisorder : The time required for random queries in ms.
- metric : test metric
- name : The name of the test metric, unify to one length.
- tag : The tag of the test metric, unify to one length.
- metricNumberTotal:The number of metrics tested.
- tagSingleNumber:Number of tags of the test metric.
- tagTotalNumber:The number of tag pools, the default is 1000, all
- tags are taken out of the tag pool.
- searchNumber:The number of queries, the default is 1000000.
- loop:The number of query loops, the default is 10.
- firstly, you need to set up some system property, for example:
System.setProperty("line.separator", "\n");
System.setProperty("IOTDB_CONF", "metrics/dropwizard-metrics/src/test/resources");
- Then, you can modify
iotdb-datanode.properties(iotdb-confignode.properties)
as you like, some details:
properties | meaning | example |
---|---|---|
dn(cn)_enable_metric | whether enable the module | true |
dn(cn)_enable_performance_stat | Is stat performance of operation latency | true |
dn(cn)_metric_reporter_list | the list of reporter | JMX, PROMETHEUS, IOTDB |
dn(cn)_metric_frame_type | The type of metric manager | DROPWIZARD, MICROMETER |
dn(cn)_metric_level | the init level of metrics | ALL, NORMAL, IMPORTANT, CORE |
dn(cn)_metric_async_collect_period | The period of the collection of some metrics in asynchronous way, such as tsfile size. | 5 |
- More details, see User Doc.
- Now, MetricService is registered as IService in server and confignode module, you can simple set properties:
dn(cn)_enable_metric=true
to use metric service. - In server module you can easily use these metric by
MetricService.getInstance()
, for example:
MetricService.getInstance().count(1, "operation_count", MetricLevel.IMPORTANT, "name", operation.getName());
- implement your MetricService
- You need to implement
reloadProperties
to reload properties when running.
- You need to implement
- implement your MetricManager
- The name of MetricManager should start with
metricFrameType
, MetricService will init manager according to the prefix of class name. - You need to create
src/main/resources/META-INF/services/org.apache.iotdb.metrics.AbstractMetricManager
,and record your MetricManager class name in this file, such asorg.apache.iotdb.metrics.dropwizard.DropwizardMetricManager
- The name of MetricManager should start with
- implement your reporter
- You need to implement jmx reporter and prometheus reporter, notice that your jmx bean name should be unified as
org.apache.iotdb.metrics
- The name of your reporter should also start with
metricFrameType
- You need to create
src/main/resources/META-INF/services/org.apache.iotdb.metrics.Reporter
,and record your MetricManager class name in this file, such asorg.apache.iotdb.metrics.dropwizard.reporter.DropwizardPrometheusReporter
- You need to implement jmx reporter and prometheus reporter, notice that your jmx bean name should be unified as
- implement your specific metric
- They are counter, gauge, histogram, histogramSnapshot, rate and timer.
- These metrics will be managed by your MetricManager, and reported by your reporter.