1818package kubernetesmetrics
1919
2020import (
21- "math"
22-
2321 "github.com/elastic/opentelemetry-lib/remappers/internal/remappedmetric"
2422 "go.opentelemetry.io/collector/pdata/pcommon"
2523 "go.opentelemetry.io/collector/pdata/pmetric"
@@ -31,8 +29,8 @@ func addKubeletMetrics(
3129 mutator func (pmetric.NumberDataPoint ),
3230) error {
3331 var timestamp pcommon.Timestamp
34- var total_transmited , total_received , node_memory_usage , filesystem_capacity , filesystem_usage int64
35- var cpu_limit_utilization , memory_limit_utilization , node_cpu_usage , pod_cpu_usage_node , pod_memory_usage_node float64
32+ var total_transmited , total_received int64
33+ var cpu_limit_utilization , memory_limit_utilization , pod_cpu_usage_node , pod_memory_usage_node float64
3634
3735 // iterate all metrics in the current scope and generate the additional Elastic kubernetes integration metrics
3836 //pod
@@ -75,31 +73,6 @@ func addKubeletMetrics(
7573 }
7674 }
7775 }
78- //node
79- } else if metric .Name () == "k8s.node.cpu.usage" {
80- dp := metric .Gauge ().DataPoints ().At (0 )
81- if timestamp == 0 {
82- timestamp = dp .Timestamp ()
83- }
84- node_cpu_usage = dp .DoubleValue () * math .Pow10 (9 )
85- } else if metric .Name () == "k8s.node.memory.usage" {
86- dp := metric .Gauge ().DataPoints ().At (0 )
87- if timestamp == 0 {
88- timestamp = dp .Timestamp ()
89- }
90- node_memory_usage = dp .IntValue ()
91- } else if metric .Name () == "k8s.node.filesystem.capacity" {
92- dp := metric .Gauge ().DataPoints ().At (0 )
93- if timestamp == 0 {
94- timestamp = dp .Timestamp ()
95- }
96- filesystem_capacity = dp .IntValue ()
97- } else if metric .Name () == "k8s.node.filesystem.usage" {
98- dp := metric .Gauge ().DataPoints ().At (0 )
99- if timestamp == 0 {
100- timestamp = dp .Timestamp ()
101- }
102- filesystem_usage = dp .IntValue ()
10376 }
10477
10578 }
@@ -147,30 +120,6 @@ func addKubeletMetrics(
147120 Timestamp : timestamp ,
148121 IntValue : & total_received ,
149122 },
150- remappedmetric.Metric {
151- DataType : pmetric .MetricTypeGauge ,
152- Name : "kubernetes.node.cpu.usage.nanocores" ,
153- Timestamp : timestamp ,
154- DoubleValue : & node_cpu_usage ,
155- },
156- remappedmetric.Metric {
157- DataType : pmetric .MetricTypeGauge ,
158- Name : "kubernetes.node.memory.usage.bytes" ,
159- Timestamp : timestamp ,
160- IntValue : & node_memory_usage ,
161- },
162- remappedmetric.Metric {
163- DataType : pmetric .MetricTypeGauge ,
164- Name : "kubernetes.node.fs.capacity.bytes" ,
165- Timestamp : timestamp ,
166- IntValue : & filesystem_capacity ,
167- },
168- remappedmetric.Metric {
169- DataType : pmetric .MetricTypeGauge ,
170- Name : "kubernetes.node.fs.used.bytes" ,
171- Timestamp : timestamp ,
172- IntValue : & filesystem_usage ,
173- },
174123 )
175124
176125 return nil
0 commit comments