parent
4445152678
commit
80648f783e
@ -290,57 +290,121 @@ func NewPrometheusCollector(infoProvider subcontainersInfoProvider) *PrometheusC
|
||||
name: "container_network_receive_bytes_total",
|
||||
help: "Cumulative count of bytes received",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.RxBytes)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.RxBytes),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_receive_packets_total",
|
||||
help: "Cumulative count of packets received",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.RxPackets)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.RxPackets),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_receive_packets_dropped_total",
|
||||
help: "Cumulative count of packets dropped while receiving",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.RxDropped)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.RxDropped),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_receive_errors_total",
|
||||
help: "Cumulative count of errors encountered while receiving",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.RxErrors)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.RxErrors),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_transmit_bytes_total",
|
||||
help: "Cumulative count of bytes transmitted",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.TxBytes)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.TxBytes),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_transmit_packets_total",
|
||||
help: "Cumulative count of packets transmitted",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.TxPackets)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.TxPackets),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_transmit_packets_dropped_total",
|
||||
help: "Cumulative count of packets dropped while transmitting",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.TxDropped)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.TxDropped),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_network_transmit_errors_total",
|
||||
help: "Cumulative count of errors encountered while transmitting",
|
||||
valueType: prometheus.CounterValue,
|
||||
extraLabels: []string{"interface"},
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Network.TxErrors)}}
|
||||
values := make(metricValues, 0, len(s.Network.Interfaces))
|
||||
for _, value := range s.Network.Interfaces {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value.TxErrors),
|
||||
labels: []string{value.Name},
|
||||
})
|
||||
}
|
||||
return values
|
||||
},
|
||||
}, {
|
||||
name: "container_tasks_state",
|
||||
|
@ -71,6 +71,19 @@ func (p testSubcontainersInfoProvider) SubcontainersInfo(string, *info.Container
|
||||
TxErrors: 20,
|
||||
TxDropped: 21,
|
||||
},
|
||||
Interfaces: []info.InterfaceStats{
|
||||
{
|
||||
Name: "eth0",
|
||||
RxBytes: 14,
|
||||
RxPackets: 15,
|
||||
RxErrors: 16,
|
||||
RxDropped: 17,
|
||||
TxBytes: 18,
|
||||
TxPackets: 19,
|
||||
TxErrors: 20,
|
||||
TxDropped: 21,
|
||||
},
|
||||
},
|
||||
},
|
||||
Filesystem: []info.FsStats{
|
||||
{
|
||||
|
16
metrics/testdata/prometheus_metrics
vendored
16
metrics/testdata/prometheus_metrics
vendored
@ -79,28 +79,28 @@ container_memory_usage_bytes{id="testcontainer",image="test",name="testcontainer
|
||||
container_memory_working_set_bytes{id="testcontainer",image="test",name="testcontainer"} 9
|
||||
# HELP container_network_receive_bytes_total Cumulative count of bytes received
|
||||
# TYPE container_network_receive_bytes_total counter
|
||||
container_network_receive_bytes_total{id="testcontainer",image="test",name="testcontainer"} 14
|
||||
container_network_receive_bytes_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 14
|
||||
# HELP container_network_receive_errors_total Cumulative count of errors encountered while receiving
|
||||
# TYPE container_network_receive_errors_total counter
|
||||
container_network_receive_errors_total{id="testcontainer",image="test",name="testcontainer"} 16
|
||||
container_network_receive_errors_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 16
|
||||
# HELP container_network_receive_packets_dropped_total Cumulative count of packets dropped while receiving
|
||||
# TYPE container_network_receive_packets_dropped_total counter
|
||||
container_network_receive_packets_dropped_total{id="testcontainer",image="test",name="testcontainer"} 17
|
||||
container_network_receive_packets_dropped_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 17
|
||||
# HELP container_network_receive_packets_total Cumulative count of packets received
|
||||
# TYPE container_network_receive_packets_total counter
|
||||
container_network_receive_packets_total{id="testcontainer",image="test",name="testcontainer"} 15
|
||||
container_network_receive_packets_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 15
|
||||
# HELP container_network_transmit_bytes_total Cumulative count of bytes transmitted
|
||||
# TYPE container_network_transmit_bytes_total counter
|
||||
container_network_transmit_bytes_total{id="testcontainer",image="test",name="testcontainer"} 18
|
||||
container_network_transmit_bytes_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 18
|
||||
# HELP container_network_transmit_errors_total Cumulative count of errors encountered while transmitting
|
||||
# TYPE container_network_transmit_errors_total counter
|
||||
container_network_transmit_errors_total{id="testcontainer",image="test",name="testcontainer"} 20
|
||||
container_network_transmit_errors_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 20
|
||||
# HELP container_network_transmit_packets_dropped_total Cumulative count of packets dropped while transmitting
|
||||
# TYPE container_network_transmit_packets_dropped_total counter
|
||||
container_network_transmit_packets_dropped_total{id="testcontainer",image="test",name="testcontainer"} 21
|
||||
container_network_transmit_packets_dropped_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 21
|
||||
# HELP container_network_transmit_packets_total Cumulative count of packets transmitted
|
||||
# TYPE container_network_transmit_packets_total counter
|
||||
container_network_transmit_packets_total{id="testcontainer",image="test",name="testcontainer"} 19
|
||||
container_network_transmit_packets_total{id="testcontainer",image="test",interface="eth0",name="testcontainer"} 19
|
||||
# HELP container_scrape_error 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE container_scrape_error gauge
|
||||
container_scrape_error 0
|
||||
|
Loading…
Reference in New Issue
Block a user