Browse Source

Merge "Convert resource timestamps to RFC3339 format for ES"

Jenkins 2 years ago
parent
commit
66cecd7f08

+ 11
- 4
deployment_scripts/puppet/modules/telemetry/files/common/resources.lua View File

@@ -14,8 +14,6 @@
14 14
 
15 15
 local cjson = cjson
16 16
 local string = string
17
-local table = table
18
-local math = math
19 17
 local setmetatable = setmetatable
20 18
 local ipairs = ipairs
21 19
 local pairs = pairs
@@ -31,7 +29,6 @@ function normalize_uuid(uuid)
31 29
     return patt.Uuid:match(uuid)
32 30
 end
33 31
 
34
-local metadata_fields = {}
35 32
 
36 33
 local ResourcesDecoder = {}
37 34
 ResourcesDecoder.__index = ResourcesDecoder
@@ -70,8 +67,18 @@ local resource_msg = {
70 67
 function add_resource_to_payload(sample, payload)
71 68
     local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
72 69
 
70
+    local metadata = sample.resource_metadata
71
+    if type(metadata) == 'table' then
72
+        for name, value in ipairs(metadata) do
73
+            local transform = transform_functions[name]
74
+            if transform ~= nil then
75
+                metadata[name] = transform(value)
76
+            end
77
+        end
78
+    end
79
+
73 80
     local resource_data = {
74
-        timestamp = sample.timestamp,
81
+        timestamp = utils.format_datetime(sample.timestamp),
75 82
         resource_id = sample.resource_id,
76 83
         source = sample.source or "",
77 84
         metadata = sample.resource_metadata,

Loading…
Cancel
Save