Skip to content

Commit

Permalink
lua logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ElDuderinos committed Jul 30, 2023
1 parent 9f236d2 commit 7be0c59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion filters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ local function get_metadata(container_id)
local config_file_path = "/var/lib/docker/containers/" .. container_id .. "/config.v2.json"
local config_file = io.open(config_file_path, "rb")
if not config_file then
io.write(string.format("no config file for %s\n",container_id))
return nil
end
local config_json = config_file:read("*a")
config_file:close()

-- Map json config
local config = cjson.decode(config_json)

io.write(string.format("container %s name %s\n",container_id, name))
return {
id = config.ID,
name = config.Name:gsub("^/", ""),
Expand All @@ -32,6 +33,8 @@ end
function enrich(tag, timestamp, record)
-- Get container id from tag
local container_id = tag:match("docker%.(.+)")
io.write(string.format("enrich %s container id\n",tag,container_id))

if not container_id then
return 0, timestamp, record
end
Expand Down

0 comments on commit 7be0c59

Please sign in to comment.