Convert resource timestamps to RFC3339 format for ES

Change-Id: Iffe442c6f855f30fb7bbbe9c39399a0bfd35db11
This commit is contained in:
Ildar Svetlov 2017-01-27 18:16:03 +04:00
parent a8f15cdc6d
commit 5494211a42
1 changed files with 11 additions and 4 deletions

View File

@ -14,8 +14,6 @@
local cjson = cjson local cjson = cjson
local string = string local string = string
local table = table
local math = math
local setmetatable = setmetatable local setmetatable = setmetatable
local ipairs = ipairs local ipairs = ipairs
local pairs = pairs local pairs = pairs
@ -31,7 +29,6 @@ function normalize_uuid(uuid)
return patt.Uuid:match(uuid) return patt.Uuid:match(uuid)
end end
local metadata_fields = {}
local ResourcesDecoder = {} local ResourcesDecoder = {}
ResourcesDecoder.__index = ResourcesDecoder ResourcesDecoder.__index = ResourcesDecoder
@ -70,8 +67,18 @@ local resource_msg = {
function add_resource_to_payload(sample, payload) function add_resource_to_payload(sample, payload)
local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\") local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
local metadata = sample.resource_metadata
if type(metadata) == 'table' then
for name, value in ipairs(metadata) do
local transform = transform_functions[name]
if transform ~= nil then
metadata[name] = transform(value)
end
end
end
local resource_data = { local resource_data = {
timestamp = sample.timestamp, timestamp = utils.format_datetime(sample.timestamp),
resource_id = sample.resource_id, resource_id = sample.resource_id,
source = sample.source or "", source = sample.source or "",
metadata = sample.resource_metadata, metadata = sample.resource_metadata,