Getting started with monitoring
Example on GitHub: sharded_cluster_crud_metrics
Tarantool allows you to configure and expose its metrics using a YAML configuration. You can also use the built-in metrics module to create and collect custom metrics.
To configure metrics, use the metrics section in a cluster configuration. The configuration below enables all metrics excluding vinyl-specific ones:
metrics:include: [ all ]exclude: [ vinyl ]labels:alias: '{{ instance_name }}'
The metrics.labels option accepts the predefined
{{ instance_name }} variable. This
adds an instance name as a label to
every observation.
Third-party Lua modules, like crud
or expirationd, offer their
own metrics. You can enable these metrics by
configuring the corresponding role.
The example below shows how to enable statistics on called operations by
providing the roles.crud-router role's configuration:
roles:- roles.crud-router- roles.metrics-exportroles_cfg:roles.crud-router:stats: truestats_driver: metricsstats_quantiles: true
expirationd metrics can be enabled as follows:
expirationd:cfg:metrics: true
To expose metrics in different formats, you can use a third-party
metrics-export-role
role. In the following example, the metrics of storage-a-001 are
provided on two endpoints:
/metrics/prometheus: exposes metrics in the Prometheus format./metrics/json: exposes metrics in the JSON format.
storage-a-001:roles_cfg:roles.metrics-export:http:- listen: '127.0.0.1:8082'endpoints:- path: /metrics/prometheus/format: prometheus- path: /metrics/jsonformat: json
Example on GitHub: sharded_cluster_crud_metrics
The metrics module allows you to create and collect custom metrics.
The example below shows how to collect the number of data operations
performed on the specified space by increasing a counter value inside
the on_replace() trigger function:
Learn more in metrics-api_reference_custom_metrics.
When metrics are configured and exposed, you can use the desired third-party tool to collect them. Below is the example of a Prometheus scrape configuration that collects metrics of multiple Tarantool instances:
global:scrape_interval: 5sevaluation_interval: 5sscrape_configs:- job_name: prometheusstatic_configs:- targets:- 127.0.0.1:8081- 127.0.0.1:8082- 127.0.0.1:8083- 127.0.0.1:8084- 127.0.0.1:8085metrics_path: "/metrics/prometheus"
For more information on collecting and visualizing metrics, refer to monitoring-grafana_dashboard-page.