Hi Jmix team,
do you recommend a certain way to get metrics (or traces) from Jmix?
I would like to monitor UI, DB and REST to find bottlenecks.
Thank you very much.
Best regards,
Martin
Hi Jmix team,
do you recommend a certain way to get metrics (or traces) from Jmix?
I would like to monitor UI, DB and REST to find bottlenecks.
Thank you very much.
Best regards,
Martin
Hi Martin,
The framework defines a dependency on io.micrometer:micrometer-core
, which enables usage of the Micrometer API in the applications.
When Spring Actuator and a Micrometer module for integration with a particular monitoring system are added to a project, the monitoring output goes to that monitoring system.
The framework exposes some metrics internally, see for example io.jmix.ui.monitoring.UiMonitoring
class. You can do the same in your applications by injecting MeterRegistry
and using its primitives (Timer, Counter, Gauge). For example:
@Autowired
private MeterRegistry meterRegistry;
@Subscribe
public void onInit(InitEvent event) {
sample = Timer.start(meterRegistry);
}
@Subscribe
public void onAfterShow(AfterShowEvent event) {
sample.stop(meterRegistry.timer("jmix.UserBrowse.init"));
}
You can use Prometheus for collecting and visualizing metrics as below.
Add the following dependencies:
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
Add to application.properties
:
management.endpoints.web.exposure.include = *
Install and configure Prometheus:
scrape_configs:
# ...
- job_name: 'spring_micrometer'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['127.0.0.1:8080']
Run Prometheus:
./prometheus --config.file=prometheus.yml
Open http://localhost:9090 and try some queries:
jmix_UserBrowse_init_seconds_sum
jmix_ui_screens_seconds_sum
sum by (lifeCycle) (jmix_ui_screens_seconds_sum)
jmix_ui_screens_seconds_sum{screen="Foo.browse"}
Regards,
Konstantin
Thank you very much.