tarantool / cartridge-metrics-role

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

Cartridge Metrics Role

cartridge.roles.metrics is a role for tarantool/cartridge. It allows to use default metrics in a Cartridge application and manage them via configuration.

Usage

  1. Add the cartridge-metrics-role package to dependencies in the .rockspec file.

    dependencies = {
        ...
        'cartridge-metrics-role == 0.1.0-1',
        ...
    }
  2. Add cartridge.roles.metrics to the roles list in cartridge.cfg in your entry-point file (e.g. init.lua).

    local ok, err = cartridge.cfg({
        ...
        roles = {
            ...
            'cartridge.roles.metrics',
            ...
        },
    })
  3. To view metrics via API endpoints, use set_export. NOTE that set_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 in format.

  4. 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')
  5. 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.

Contacts

If you have questions, please ask it on StackOverflow or contact us in Telegram:

About

License:MIT License


Languages

Language:Lua 97.7%Language:Makefile 1.3%Language:CMake 1.0%