Skip to content

Commit

Permalink
addition of bandwidth and storage metrics (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: Abdul Qadeer <[email protected]>
  • Loading branch information
jpedro1992 and Abdul Qadeer authored Mar 17, 2023
1 parent 3294221 commit 3a210d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
33 changes: 21 additions & 12 deletions pkg/watcher/internal/metricsprovider/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ import (
)

const (
EnableOpenShiftAuth = "ENABLE_OPENSHIFT_AUTH"
DefaultPromAddress = "http://prometheus-k8s:9090"
promStd = "stddev_over_time"
promAvg = "avg_over_time"
promCpuMetric = "instance:node_cpu:ratio"
promMemMetric = "instance:node_memory_utilisation:ratio"
allHosts = "all"
hostMetricKey = "instance"
defaultKubeConfig = "~/.kube/config"
EnableOpenShiftAuth = "ENABLE_OPENSHIFT_AUTH"
DefaultPromAddress = "http://prometheus-k8s:9090"
promStd = "stddev_over_time"
promAvg = "avg_over_time"
promCpuMetric = "instance:node_cpu:ratio"
promMemMetric = "instance:node_memory_utilisation:ratio"
promTransBandMetric = "instance:node_network_transmit_bytes:rate:sum"
promTransBandDropMetric = "instance:node_network_transmit_drop_excluding_lo:rate5m"
promRecBandMetric = "instance:node_network_receive_bytes:rate:sum"
promRecBandDropMetric = "instance:node_network_receive_drop_excluding_lo:rate5m"
promDiskIOMetric = "instance_device:node_disk_io_time_seconds:rate5m"
allHosts = "all"
hostMetricKey = "instance"
defaultKubeConfig = "~/.kube/config"
)

type promClient struct {
Expand Down Expand Up @@ -167,7 +172,7 @@ func (s promClient) FetchHostMetrics(host string, window *watcher.Window) ([]wat
var anyerr error

for _, method := range []string{promAvg, promStd} {
for _, metric := range []string{promCpuMetric, promMemMetric} {
for _, metric := range []string{promCpuMetric, promMemMetric, promTransBandMetric, promTransBandDropMetric, promRecBandMetric, promRecBandDropMetric, promDiskIOMetric} {
promQuery := s.buildPromQuery(host, metric, method, window.Duration)
promResults, err := s.getPromResults(promQuery)

Expand All @@ -191,7 +196,7 @@ func (s promClient) FetchAllHostsMetrics(window *watcher.Window) (map[string][]w
var anyerr error

for _, method := range []string{promAvg, promStd} {
for _, metric := range []string{promCpuMetric, promMemMetric} {
for _, metric := range []string{promCpuMetric, promMemMetric, promTransBandMetric, promTransBandDropMetric, promRecBandMetric, promRecBandDropMetric, promDiskIOMetric} {
promQuery := s.buildPromQuery(allHosts, metric, method, window.Duration)
promResults, err := s.getPromResults(promQuery)

Expand Down Expand Up @@ -264,8 +269,12 @@ func (s promClient) promResults2MetricMap(promresults model.Value, metric string

if metric == promCpuMetric {
metricType = watcher.CPU
} else {
} else if metric == promMemMetric {
metricType = watcher.Memory
} else if metric == promDiskIOMetric {
metricType = watcher.Storage
} else {
metricType = watcher.Bandwidth
}

if method == promAvg {
Expand Down
2 changes: 2 additions & 0 deletions pkg/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const (
FiveMinutes = "5m"
CPU = "CPU"
Memory = "Memory"
Bandwidth = "Bandwidth"
Storage = "Storage"
Average = "AVG"
Std = "STD"
Latest = "Latest"
Expand Down

0 comments on commit 3a210d2

Please sign in to comment.