Metric Module
-
In this project, we provide the metrics interface and its default implementation
- metrics-interface
- metrics-core
-
The built-in implementation supports the following reporters
- JMX Reporter
- Prometheus Reporter
- IoTDB Reporter
The acquisition system consists of following four parts.
- Metrics: Provide tools for collecting metrics in different scenarios, including Counter, AutoGauge, 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.
Configure the metrics module through iotdb-system.properties. The main options supported by the current code are listed below.
| properties | meaning | example |
|---|---|---|
dn(cn)_metric_reporter_list |
Reporter list. The current implementation supports JMX, PROMETHEUS and IOTDB. |
JMX,PROMETHEUS |
dn(cn)_metric_level |
Initial metric level. | OFF, CORE, IMPORTANT, NORMAL, ALL |
cn_metric_prometheus_reporter_port |
Prometheus HTTP port for ConfigNode. | 9091 |
dn_metric_prometheus_reporter_port |
Prometheus HTTP port for DataNode. | 9092 |
More details, see the User Guide and the iotdb-system.properties.template file.
MetricServiceis registered as anIServicein both DataNode and ConfigNode modules. Enable it withdn(cn)_enable_metric=true.- In server-side code you can use metrics through
MetricService.getInstance(), for example:
MetricService.getInstance().count(1, "operation_count", MetricLevel.IMPORTANT, "name", operation.getName());- If you want to bind or remove a metric set, use
addMetricSet(IMetricSet)andremoveMetricSet(IMetricSet).
- Implement your metric types and an
AbstractMetricManager.- The built-in implementation provides Counter, AutoGauge, Gauge, Histogram, Rate and Timer.
- Implement your reporters.
- Implement
Reporterfor a general reporter. - Implement
JmxReporterif you need JMX registration. The built-in JMX domain isorg.apache.iotdb.metrics.
- Implement
- Wire your implementation into the server-side metric service.
- The current
MetricServicedirectly loadsIoTDBMetricManager,IoTDBJmxReporter,PrometheusReporterandIoTDBSessionReporterinloadManager()andloadReporter(). - If you replace the default framework, update the corresponding loading logic there.
- The current
- Keep service descriptor files consistent if your packaging depends on them.
src/main/resources/META-INF/services/org.apache.iotdb.metrics.AbstractMetricManagersrc/main/resources/META-INF/services/org.apache.iotdb.metrics.reporter.JmxReporter