Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `tnt_memory` metric.
- `tnt_memory_virt` metric.
- `tnt_schema_needs_upgrade` metric.

### Changed

Expand Down
20 changes: 18 additions & 2 deletions doc/monitoring/metrics_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ General instance information:
* - ``tnt_read_only``
- Indicates if the instance is in read-only mode (``1`` if true, ``0`` if false)

.. _metrics-reference-memory_general:
.. _metrics-reference-schema:

Schema
------

Schema state metrics.

.. container:: table

.. list-table::
:widths: 25 75
:header-rows: 0

* - ``tnt_schema_needs_upgrade``
- Indicates if the instance schema requires an upgrade (``1`` when upgrade is needed, ``0`` when schema is up to date)

.. _metrics-reference-instance:

Instance metrics
----------------
Expand All @@ -45,7 +61,7 @@ These metrics can be used to monitor instance CPU and RAM usage.
* - ``tnt_memory_virt``
- Virtual memory size in bytes used by Tarantool instance (available on Linux).

.. _metrics-reference-instance:
.. _metrics-reference-memory_general:

Memory general
--------------
Expand Down
1 change: 1 addition & 0 deletions metrics/tarantool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local default_metrics = {
event_loop = require('metrics.tarantool.event_loop'),
config = require('metrics.tarantool.config'),
cpu_extended = require('metrics.psutils.cpu'),
schema = require('metrics.tarantool.schema')
}

local all_metrics_map = {}
Expand Down
32 changes: 32 additions & 0 deletions metrics/tarantool/schema.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local utils = require('metrics.utils')
-- luacheck: globals box

local collectors_list = {}

local metric_name = 'schema_needs_upgrade'

local needs_upgrade_status = {
[true] = 1,
[false] = 0,
}

local function update_schema_metrics()
if not utils.box_is_configured() then
return
end

local ok, needs_upgrade = pcall(box.schema_needs_upgrade)
if not ok then
ok, needs_upgrade = pcall(box.internal.schema_needs_upgrade)
end

if ok then
collectors_list[metric_name] = utils.set_gauge(metric_name, 'Schema needs upgrade',
needs_upgrade_status[needs_upgrade], nil, nil, {default = true})
end
end

return {
update = update_schema_metrics,
list = collectors_list,
}
25 changes: 25 additions & 0 deletions test/tarantool/schema_test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require('strict').on()

local t = require('luatest')
local g = t.group()

local utils = require('test.utils')

g.before_all(utils.create_server)

g.after_all(utils.drop_server)

g.test_needs_upgrade = function(cg)
cg.server:exec(function()
local metrics = require('metrics')
local schema = require('metrics.tarantool.schema')
local utils = require('test.utils') -- luacheck: ignore 431

metrics.enable_default_metrics()
schema.update()
local default_metrics = metrics.collect()
local schema_needs_upgrade_metric = utils.find_metric('tnt_schema_needs_upgrade', default_metrics)
t.assert(schema_needs_upgrade_metric)
t.assert_type(schema_needs_upgrade_metric[1].value, 'number')
end)
end
Loading