3. How to use?
3.1. Configuration
- 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.
3.2. Use Guide in IoTDB Server Module
- 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());
4. How to implement your own metric framework?
- implement your MetricService
- You need to implement
reloadProperties
to reload properties when running.
- 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 as org.apache.iotdb.metrics.dropwizard.DropwizardMetricManager
- 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 as org.apache.iotdb.metrics.dropwizard.reporter.DropwizardPrometheusReporter
- 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.
5. Some docs
- Metric Tool
- Metric Tool(zh)