Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry gap: Add PerfMetricsCount and HPACount metrics #1131

Merged
merged 6 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
21 changes: 21 additions & 0 deletions source/plugins/ruby/in_cadvisor_perf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def initialize
@namespaces = []
@namespaceFilteringMode = "off"
@agentConfigRefreshTracker = DateTime.now.to_time.to_i
@cadvisorPerfTelemetryTicker = DateTime.now.to_time.to_i
@totalPerfCount = 0
end

config_param :run_interval, :time, :default => 60
Expand Down Expand Up @@ -62,6 +64,7 @@ def enumerate()
time = Fluent::Engine.now
batchTime = currentTime.utc.iso8601
@@istestvar = ENV["ISTEST"]
telemetryFlush = false
begin
eventStream = Fluent::MultiEventStream.new
insightsMetricsEventStream = Fluent::MultiEventStream.new
Expand Down Expand Up @@ -101,6 +104,24 @@ def enumerate()
$log.info("cAdvisorPerfEmitStreamSuccess @ #{Time.now.utc.iso8601}")
end

if metricData.length > 0
@totalPerfCount += metricData.length
end

#send the number of CAdvisor Perf records sent metrics telemetry
timeDifference = (DateTime.now.to_time.to_i - @cadvisorPerfTelemetryTicker).abs
timeDifferenceInMinutes = timeDifference / 60
if (timeDifferenceInMinutes >= 5)
telemetryFlush = true
end

if telemetryFlush
ApplicationInsightsUtility.sendMetricTelemetry("PerfMetricCount", @totalPerfCount, {})
jatakiajanvi12 marked this conversation as resolved.
Show resolved Hide resolved
@cadvisorPerfTelemetryTicker = DateTime.now.to_time.to_i
@totalPerfCount = 0
end


#start GPU InsightsMetrics items
begin
if !@@isWindows.nil? && @@isWindows == false
Expand Down
6 changes: 4 additions & 2 deletions source/plugins/ruby/in_kubestate_hpa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def initialize
@namespaces = []
@namespaceFilteringMode = "off"
@agentConfigRefreshTracker = DateTime.now.to_time.to_i
@totalHPACount = 0
end

config_param :run_interval, :time, :default => 60
Expand Down Expand Up @@ -130,9 +131,8 @@ def enumerate

# Flush AppInsights telemetry once all the processing is done, only if the number of events flushed is greater than 0
if (@hpaCount > 0)
# this will not be a useful telemetry, as hpa counts will not be huge, just log for now
$log.info("in_kubestate_hpa::hpaCount= #{hpaCount}")
#ApplicationInsightsUtility.sendMetricTelemetry("HPACount", @hpaCount, {})
@totalHPACount += @hpaCount
end

# Adding telemetry to send kubestateHPA telemetry every 5 minutes
Expand All @@ -144,7 +144,9 @@ def enumerate

if telemetryFlush
ApplicationInsightsUtility.sendCustomEvent("KubeStateHPAHeartBeatEvent", {})
ApplicationInsightsUtility.sendMetricTelemetry("HPACount", @totalHPACount, {})
@kubeStateHPATelemetryTimeTracker = DateTime.now.to_time.to_i
@totalHPACount = 0
end
rescue => errorStr
$log.warn "in_kubestate_hpa::enumerate:Failed in enumerate: #{errorStr}"
Expand Down
19 changes: 19 additions & 0 deletions source/plugins/ruby/in_win_cadvisor_perf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def initialize
@namespaces = []
@namespaceFilteringMode = "off"
@agentConfigRefreshTracker = DateTime.now.to_time.to_i
@winCadvisorPerfTelemetryTicker = DateTime.now.to_time.to_i
@totalPerfCount = 0
end

config_param :run_interval, :time, :default => 60
Expand Down Expand Up @@ -109,6 +111,23 @@ def enumerate()
$log.info("winCAdvisorPerfEmitStreamSuccess @ #{Time.now.utc.iso8601}")
end

if metricData.length > 0
@totalPerfCount += metricData.length
end

#send the number of CAdvisor Perf records sent metrics telemetry
timeDifference = (DateTime.now.to_time.to_i - @winCadvisorPerfTelemetryTicker).abs
timeDifferenceInMinutes = timeDifference / 60
if (timeDifferenceInMinutes >= 5)
telemetryFlush = true
end

if telemetryFlush
ApplicationInsightsUtility.sendMetricTelemetry("PerfMetricCount", @totalPerfCount, {})
jatakiajanvi12 marked this conversation as resolved.
Show resolved Hide resolved
@winCadvisorPerfTelemetryTicker = DateTime.now.to_time.to_i
@totalPerfCount = 0
end

#start GPU InsightsMetrics items
begin
containerGPUusageInsightsMetricsDataItems = []
Expand Down
Loading