roles.metrics-export is a role for Tarantool 3. It allows to export metrics
from Tarantool 3. For now only export via HTTP is supported.
- Add the
metrics-export-rolepackage to dependencies in the .rockspec file.
dependencies = {
...
'metrics-export-role == 0.3.0-1',
...
}And re-build an application:
tt buildBe careful, it is better to use a latest release version.
- Enable and configure
the
roles.metrics-exportrole for a Tarantool 3 instance. Use httpd role orlistenfield in to configure server instances. See below to get more detailed information about it.
groups:
group-001:
replicasets:
replicaset-001:
instances:
master:
roles: [roles.httpd, roles.metrics-export]
roles_cfg:
roles.httpd:
default:
listen: '127.0.0.1:8083'
additional:
listen: 8084
roles.metrics-export:
http:
- endpoints:
- path: /metrics/json
format: json
- server: 'additional'
endpoints:
- path: /metrics/prometheus
format: prometheus
- listen: 8081
endpoints:
- path: /metrics/json
format: json
- path: /metrics/prometheus/
format: prometheus
- listen: 'my_host:8082'
endpoints:
- path: /metrics/prometheus
format: prometheus
- path: /metrics/json/
format: jsonIn the example above, we configure four HTTP servers. There are serveral server fields:
- first with
serverfield which refers to anadditionalserver in thehttpdrole; - the next one, with no info about server, is configured with
defaultname inhttpdconfig; - and the last two
listenfields (0.0.0.0:8081andmy_host:8082) that are listed directly.
The servers will be running on the master Tarantool instance.
Each server has two endpoints:
/metrics/jsonexports metrics with JSON format./metrics/prometheusexports metrics with Prometheus-compatible format.
The role configuration at the top level could be described as:
export_target: optsFor now only http target is supported. The target allows to export metrics via
HTTP-servers. The target could be configured as an array of servers.
Each server must have listen param that could be a port (number) or a string
in the format host:port. The address will be used by HTTP server to listen
requests.
Each server could have endpoints param as an array of endpoints to process
incoming requests. An individual endpoint can be described as:
- path: /path/to/export/on/the/server
format: format_to_exportOptionally, you can enable
http metrics
for each endpoint. For this you should
set metrics.enabled to true:
- path: /path/to/export/on/the/server
format: format_to_export
metrics:
enabled: trueFor now only json and prometheus formats are supported.
Use httpd role as well.
To enable it, you need to fill server field with name that was configured in roles.httpd block
instead of listen like it was earlier. To configure httpd role you need to write block in roles_cfg
section:
roles_cfg:
roles.httpd:
default:
listen: 8081
additional:
listen: '127.0.0.1:8082'After it you can use server name in roles.metrics-export block. If server and listen names
wasn't provided, the default server from httpd role configuration will be used:
roles.metrics-export:
http:
- server: 'additional'
endpoints:
...
- endpoints:
...So now it is possible to mix server and listen parameteres.
Let's put it all together now:
roles_cfg:
roles.httpd:
default:
listen: 8081
additional:
listen: '127.0.0.1:8082'
roles.metrics-export:
http:
- listen: 8081
endpoints:
- path: /metrics
format: json
- path: /metrics/prometheus/
format: prometheus
- listen: '127.0.0.1:8082'
endpoints:
- path: /metrics/
format: json
metrics:
enabled: true
- server: 'additional'
endpoints:
- path: /metrics
format: json
- endpoints:
- path: /metrics
format: prometheus
metrics:
enabled: trueIt is possible to configure metrics-export-role with TLS options for
listen parameter as well. To enable it, provide at least one of the
following parameters:
* `ssl_cert_file` is a path to the SSL cert file, mandatory;
* `ssl_key_file` is a path to the SSL key file, mandatory;
* `ssl_ca_file` is a path to the SSL CA file, optional;
* `ssl_ciphers` is a colon-separated list of SSL ciphers, optional;
* `ssl_password` is a password for decrypting SSL private key, optional;
* `ssl_password_file` is a SSL file with key for decrypting SSL private key, optional.
See an example below:
roles_cfg:
roles.httpd:
default:
listen: 8081
additional:
listen: '127.0.0.1:8082'
roles.metrics-export:
http:
- listen: 8081
ssl_cert_file: "/path/to/ssl_cert_file"
ssl_key_file: "/path/to/ssl_key_file"
ssl_ca_file: "/path/to/ssl_ca_file"
ssl_ciphers: "/path/to/ssl_ciphers"
ssl_password: "/path/to/ssl_password"
ssl_password_file: "/path/to/ssl_password_file"
endpoints:
- path: /metrics
format: json
- path: /metrics/prometheus/
format: prometheusWith this configuration, metrics can be obtained on this machine with the Tarantool instance as follows:
curl -XGET 127.0.0.1:8081/metrics
# Metrics will be returned in JSON format.
curl -XGET 127.0.0.1:8081/metrics/prometheus
# Metrics will be returned in Prometheus-compatible format.
curl -XGET 127.0.0.1:8082/metrics
# Metrics will be returned in JSON format.First you need to clone the repository:
git clone https://github.com/tarantool/metrics-export-role
cd metrics-export-roleAfter that you need to install dependencies (tt is required).
To do it, run:
make depsIt's possible to install requirements only for running tests or linter check. To install only tests requirements, run:
make deps depname=testTo install tests with coverage requirements, run:
make deps depname=coverageTo install linter checks, run:
make deps depname=lintAt this point you could run tests (tarantool 3 is required):
make testAnd a linter:
make luacheck