Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions source/code/plugin/filter_inventory2mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Inventory2MdmFilter < Filter
"namespace": "insights.container/pods",
"dimNames": [
"phase",
"namespace",
"Kubernetes namespace",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you want to add 'Kubernetes' ?

Copy link
Member

@vishiy vishiy Feb 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to already existing "namespace"? But thats at different level.

"node",
"controllerName"
],
Expand All @@ -77,7 +77,9 @@ class Inventory2MdmFilter < Filter
}
}
}'


@@pod_phase_values = ['Running', 'Pending', 'Succeeded', 'Failed', 'Unknown']

@process_incoming_stream = true

def initialize
Expand Down Expand Up @@ -151,7 +153,7 @@ def process_node_inventory_records(es)
def process_pod_inventory_records(es)
timestamp = DateTime.now
pod_count_hash = Hash.new

no_phase_dim_values_hash = Hash.new
begin
records = []
es.each{|time,record|
Expand All @@ -173,6 +175,29 @@ def process_pod_inventory_records(es)
pod_count = 1
pod_count_hash[pod_key] = pod_count
end

# Collect all possible combinations of dimension values other than pod phase
key_without_phase_dim_value = [podNodeDimValue, podNamespaceDimValue, podControllerNameDimValue].join('~~')
if no_phase_dim_values_hash.key?(key_without_phase_dim_value)
@log.info "#{key_without_phase_dim_value} already present in #{no_phase_dim_values_hash}"
next
else
@log.info "Adding #{key_without_phase_dim_value} to #{no_phase_dim_values_hash}"
no_phase_dim_values_hash[key_without_phase_dim_value] = true
end
}

# generate all possible values of non_phase_dim_values X pod Phases and zero-fill the ones that are not already present
no_phase_dim_values_hash.each {|key, value|
@@pod_phase_values.each{|phase|
pod_key = [key, phase].join('~~')
if !pod_count_hash.key?(pod_key)
pod_count_hash[pod_key] = 0
@log.info "Zero filled #{pod_key}"
else
next
end
}
}

pod_count_hash.each {|key, value|
Expand Down