Implement timeseries cleanup

Closes #1940
This commit is contained in:
emanuele-f 2018-09-11 17:16:56 +02:00
parent 433cbb3142
commit ffe2c629bc
7 changed files with 117 additions and 46 deletions

View file

@ -791,4 +791,22 @@ end
-- ##############################################
function driver:delete(schema_prefix, tags)
local url = self.url
local measurement_pattern = ternary(schema_prefix == "", '//', '/^'.. schema_prefix ..':/')
local query = 'DELETE FROM '.. measurement_pattern ..' WHERE ' .. table.tconcat(tags, "=", " AND ", nil, "'")
local full_url = url .. "/query?db=".. self.db .."&q=" .. urlencode(query)
local res = ntop.httpGet(full_url, self.username, self.password, INFLUX_QUERY_TIMEMOUT_SEC, true)
if not res or (res.RESPONSE_CODE ~= 200) then
traceError(TRACE_ERROR, TRACE_CONSOLE, getResponseError(res))
return false
end
return true
end
-- ##############################################
return driver