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

add filtering judgment for the kube_pod_volcano_container_status_runn… #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
76 changes: 40 additions & 36 deletions internal/store/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,14 @@ func podMetricFamilies(allowLabelsList []string) []generator.FamilyGenerator {
wrapPodFunc(func(p *v1.Pod) *metric.Family {
ms := make([]*metric.Metric, len(p.Status.ContainerStatuses))

for i, cs := range p.Status.ContainerStatuses {
ms[i] = &metric.Metric{
LabelKeys: []string{"container", "job_name", "queue"},
LabelValues: []string{cs.Name, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"]},
Value: boolFloat64(cs.State.Running != nil),
if _, ok := p.Labels["volcano.sh/job-name"]; ok {

for i, cs := range p.Status.ContainerStatuses {
ms[i] = &metric.Metric{
LabelKeys: []string{"container", "job_name", "queue"},
LabelValues: []string{cs.Name, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"]},
Value: boolFloat64(cs.State.Running != nil),
}
}
}

Expand Down Expand Up @@ -906,49 +909,50 @@ func podMetricFamilies(allowLabelsList []string) []generator.FamilyGenerator {
"",
wrapPodFunc(func(p *v1.Pod) *metric.Family {
ms := []*metric.Metric{}
if _, ok := p.Labels["volcano.sh/job-name"]; ok {

for _, c := range p.Spec.Containers {
req := c.Resources.Requests
for _, c := range p.Spec.Containers {
req := c.Resources.Requests

for resourceName, val := range req {
switch resourceName {
case v1.ResourceCPU:
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitCore)},
Value: float64(val.MilliValue()) / 1000,
})
case v1.ResourceStorage:
fallthrough
case v1.ResourceEphemeralStorage:
fallthrough
case v1.ResourceMemory:
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitByte)},
Value: float64(val.Value()),
})
default:
if isHugePageResourceName(resourceName) {
for resourceName, val := range req {
switch resourceName {
case v1.ResourceCPU:
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitByte)},
Value: float64(val.Value()),
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitCore)},
Value: float64(val.MilliValue()) / 1000,
})
}
if isAttachableVolumeResourceName(resourceName) {
case v1.ResourceStorage:
fallthrough
case v1.ResourceEphemeralStorage:
fallthrough
case v1.ResourceMemory:
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitByte)},
Value: float64(val.Value()),
})
}
if isExtendedResourceName(resourceName) {
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitInteger)},
Value: float64(val.Value()),
})
default:
if isHugePageResourceName(resourceName) {
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitByte)},
Value: float64(val.Value()),
})
}
if isAttachableVolumeResourceName(resourceName) {
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitByte)},
Value: float64(val.Value()),
})
}
if isExtendedResourceName(resourceName) {
ms = append(ms, &metric.Metric{
LabelValues: []string{c.Name, p.Spec.NodeName, p.Namespace, p.Labels["volcano.sh/job-name"], p.Labels["volcano.sh/queue-name"], sanitizeLabelName(string(resourceName)), string(constant.UnitInteger)},
Value: float64(val.Value()),
})
}
}
}
}
}

for _, metric := range ms {
metric.LabelKeys = []string{"container", "node", "volcano_namespace", "volcano_job", "queue", "resource", "unit"}
}
Expand Down