Skip to content

Commit

Permalink
processor: Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ridwanmsharif committed Jun 7, 2022
1 parent 99957ab commit 8c28ae5
Show file tree
Hide file tree
Showing 184 changed files with 3,000 additions and 2,811 deletions.
5 changes: 4 additions & 1 deletion confgenerator/fluentbit/parser_deduplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ function merge(record, parsedRecord)
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ function merge(record, parsedRecord)
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
Match pipeline3.test_syslog_source_id_tcp
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline3.test_syslog_source_id_tcp
Expand All @@ -135,7 +135,7 @@
Match pipeline4.test_syslog_source_id_udp
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline4.test_syslog_source_id_udp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ function merge(record, parsedRecord)
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
Match pipeline1.sample_logs
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline1.sample_logs
Expand All @@ -115,7 +115,7 @@
Match pipeline1.sample_logs
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline1.sample_logs
Expand All @@ -140,7 +140,7 @@
Match pipeline2.sample_logs
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline2.sample_logs
Expand All @@ -159,7 +159,7 @@
Match pipeline2.sample_logs
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline2.sample_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ function merge(record, parsedRecord)
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
Match pipeline1.log_source_id1
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline1.log_source_id1
Expand All @@ -123,7 +123,7 @@
Match pipeline2.log_source_id2
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline2.log_source_id2
Expand All @@ -148,7 +148,7 @@
Match pipeline3.test_syslog_source_id_tcp
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline3.test_syslog_source_id_tcp
Expand All @@ -173,7 +173,7 @@
Match pipeline4.test_syslog_source_id_udp
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match pipeline4.test_syslog_source_id_udp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ function merge(record, parsedRecord)
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
Match default_pipeline.syslog
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Match default_pipeline.syslog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

function shallow_merge(record, parsedRecord)
-- If no exiting record exists
if (record == nil) then
return parsedRecord
end

for k, v in pairs(parsedRecord) do
record[k] = v
end

return record
end

function merge(record, parsedRecord)
-- If no exiting record exists
if record == nil then
return parsedRecord
end

-- Potentially overwrite or merge the original records.
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
end
end

return record
end

function parser_merge_record(tag, timestamp, record)
originalPayload = record["logging.googleapis.com/__tmp"]
if originalPayload == nil then
return 0, timestamp, record
end

-- Remove original payload
record["logging.googleapis.com/__tmp"] = nil
record = merge(originalPayload, record)
return 2, timestamp, record
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
Match apache.apache_access
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Condition Key_Value_Equals http_request_remoteIp -
Expand Down Expand Up @@ -153,7 +153,7 @@
Match apache.apache_error
Name lua
call parser_merge_record
script d3ec85a195ff5cdac07365a78338e96f.lua
script 5fc5f42c16c9e1ab8292e3d42f74f3be.lua

[FILTER]
Add logging.googleapis.com/severity EMERGENCY
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

function shallow_merge(record, parsedRecord)
-- If no exiting record exists
if (record == nil) then
return parsedRecord
end

for k, v in pairs(parsedRecord) do
record[k] = v
end

return record
end

function merge(record, parsedRecord)
-- If no exiting record exists
if record == nil then
return parsedRecord
end

-- Potentially overwrite or merge the original records.
for k, v in pairs(parsedRecord) do
-- If there is no conflict
if k == "logging.googleapis.com/logName" then
-- Ignore the parsed payload since the logName is controlled
-- by the OpsAgent.
elseif k == "logging.googleapis.com/labels" then
-- LogEntry.labels are basically a map[string]string and so only require a
-- shallow merge (one level deep merge).
record[k] = shallow_merge(record[k], v)
else
record[k] = v
end
end

return record
end

function parser_merge_record(tag, timestamp, record)
originalPayload = record["logging.googleapis.com/__tmp"]
if originalPayload == nil then
return 0, timestamp, record
end

-- Remove original payload
record["logging.googleapis.com/__tmp"] = nil
record = merge(originalPayload, record)
return 2, timestamp, record
end

This file was deleted.

Loading

0 comments on commit 8c28ae5

Please sign in to comment.