cartridge.roles.metrics
is a role for
tarantool/cartridge.
It allows to use default metrics in a Cartridge application and manage them
via configuration.
-
Add the
cartridge-metrics-role
package to dependencies in the.rockspec
file.dependencies = { ... 'cartridge-metrics-role == 0.1.0-1', ... }
-
Add
cartridge.roles.metrics
to the roles list incartridge.cfg
in your entry-point file (e.g.init.lua
).local ok, err = cartridge.cfg({ ... roles = { ... 'cartridge.roles.metrics', ... }, })
-
To view metrics via API endpoints, use
set_export
. NOTE thatset_export
has lower priority than clusterwide config and could be overriden by the metrics config.local metrics = require('cartridge.roles.metrics') metrics.set_export({ { path = '/path_for_json_metrics', format = 'json' }, { path = '/path_for_prometheus_metrics', format = 'prometheus' }, { path = '/health', format = 'health' } })
You can add several entry points of the same format by different paths, like this:
metrics.set_export({ { path = '/path_for_json_metrics', format = 'json' }, { path = '/another_path_for_json_metrics', format = 'json' }, })
The metrics will be available on the path specified in
path
in the format specified informat
. -
After role initialization, default metrics will be enabled and the global label 'alias' will be set. If you need to use the functionality of any metrics package, you may get it as a Cartridge service and use it like a regular package after
require
:local cartridge = require('cartridge') local metrics = cartridge.service_get('metrics')
-
There is an ability in Tarantool Cartridge >= '2.4.0' to set a zone for each server in a cluster. If a zone was set for the server 'zone' label will be added for all metrics on this server.
This repository is a former part of metrics repository.
Metrics is a library to collect and expose Tarantool-based applications metrics. You can see related documentation here.
If you have questions, please ask it on StackOverflow or contact us in Telegram: