Kong Gateway (OSS)
2.3.x
Maybe you were looking for the Kong Gateway (Enterprise) documentation
instead?
You are browsing documentation for an outdated version. See the
latest documentation here.
kong.node
kong.node
Node-level utilities
kong.node.get_id()
Returns the id used by this node to describe itself.
Returns
string
The v4 UUID used by this node as its id
Usage
1
local id = kong.node.get_id()
kong.node.get_memory_stats([unit[, scale]])
Returns memory usage statistics about this node.
Parameters
- unit (string, optional): The unit memory should be reported in. Can be
either of
b/B
,k/K
,m/M
, org/G
for bytes, kibibytes, mebibytes, or gibibytes, respectively. Defaults tob
(bytes). - scale (number, optional): The number of digits to the right of the decimal point. Defaults to 2.
Returns
table
A table containing memory usage statistics for this node. Ifunit
isb/B
(the default) reported values will be Lua numbers. Otherwise, reported values will be a string with the unit as a suffix.
Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local res = kong.node.get_memory_stats()
-- res will have the following structure:
{
lua_shared_dicts = {
kong = {
allocated_slabs = 12288,
capacity = 24576
},
kong_db_cache = {
allocated_slabs = 12288,
capacity = 12288
}
},
workers_lua_vms = {
{
http_allocated_gc = 1102,
pid = 18004
},
{
http_allocated_gc = 1102,
pid = 18005
}
}
}
local res = kong.node.get_memory_stats("k", 1)
-- res will have the following structure:
{
lua_shared_dicts = {
kong = {
allocated_slabs = "12.0 KiB",
capacity = "24.0 KiB",
},
kong_db_cache = {
allocated_slabs = "12.0 KiB",
capacity = "12.0 KiB",
}
},
workers_lua_vms = {
{
http_allocated_gc = "1.1 KiB",
pid = 18004
},
{
http_allocated_gc = "1.1 KiB",
pid = 18005
}
}
}
kong.node.get_hostname()
Returns the name used by the local machine
Returns
string
The local machine hostname
Usage
1
local hostname = kong.node.get_hostname()