mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
parent
f843233e99
commit
d65f7dc126
3 changed files with 33 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ package.path = dirs.installdir .. "/scripts/lua/modules/datasources/?.lua;" .. p
|
|||
|
||||
local json = require "dkjson"
|
||||
local rest_utils = require "rest_utils"
|
||||
local template = require "resty.template"
|
||||
-- Import the classes library.
|
||||
local classes = require "classes"
|
||||
|
||||
|
|
@ -118,6 +119,25 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Returns instance metadata, which depends on the current instance and parsed_params
|
||||
function datasource:get_metadata()
|
||||
local res = {}
|
||||
|
||||
-- Render a url with submitted parsed_params
|
||||
if self.meta.url then
|
||||
local url_func = template.compile(self.meta.url, nil, true)
|
||||
local url_rendered = url_func({
|
||||
params = self.parsed_params,
|
||||
})
|
||||
|
||||
res["url"] = url_rendered
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Transform data according to the specified transformation
|
||||
-- @param data The data to be transformed
|
||||
-- @param transformation The transformation to be applied
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ packet_distro.meta = {
|
|||
params = {
|
||||
"ifid" -- validated according to http_lint.lua
|
||||
},
|
||||
-- A URL possibly formatted with parsed_params sent via REST
|
||||
url = "/lua/if_stats.lua?ifid={{ params.ifid }}&page=packets",
|
||||
-- Possibly add placeholders to replace keys and values, e.g.,
|
||||
-- k is the `k` in the response data, v is the `v` in the response data
|
||||
-- url = "/lua/if_stats.lua?ifid={{ params.ifid }}&page=packets&key=__k__&value=__v__",
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
|
@ -57,6 +62,8 @@ packet_distro.labels = {
|
|||
function packet_distro:init()
|
||||
-- Call the parent constructor
|
||||
self.super:init()
|
||||
|
||||
self.datasource_key_str = datasource_keys[datasource.ds_type]
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue