@@ -1541,15 +1541,12 @@ func createPodStatusReasonFamilyGenerator() generator.FamilyGenerator {
1541
1541
ms := []* metric.Metric {}
1542
1542
1543
1543
for _ , reason := range podStatusReasons {
1544
- metric := & metric.Metric {}
1545
- metric .LabelKeys = []string {"reason" }
1546
- metric .LabelValues = []string {reason }
1547
- if p .Status .Reason == reason {
1548
- metric .Value = boolFloat64 (true )
1549
- } else {
1550
- metric .Value = boolFloat64 (false )
1544
+ m := & metric.Metric {
1545
+ LabelKeys : []string {"reason" },
1546
+ LabelValues : []string {reason },
1547
+ Value : getPodStatusReasonValue (p , reason ),
1551
1548
}
1552
- ms = append (ms , metric )
1549
+ ms = append (ms , m )
1553
1550
}
1554
1551
1555
1552
return & metric.Family {
@@ -1559,6 +1556,23 @@ func createPodStatusReasonFamilyGenerator() generator.FamilyGenerator {
1559
1556
)
1560
1557
}
1561
1558
1559
+ func getPodStatusReasonValue (p * v1.Pod , reason string ) float64 {
1560
+ if p .Status .Reason == reason {
1561
+ return 1
1562
+ }
1563
+ for _ , cond := range p .Status .Conditions {
1564
+ if cond .Reason == reason {
1565
+ return 1
1566
+ }
1567
+ }
1568
+ for _ , cs := range p .Status .ContainerStatuses {
1569
+ if cs .State .Terminated != nil && cs .State .Terminated .Reason == reason {
1570
+ return 1
1571
+ }
1572
+ }
1573
+ return 0
1574
+ }
1575
+
1562
1576
func createPodStatusScheduledFamilyGenerator () generator.FamilyGenerator {
1563
1577
return * generator .NewFamilyGeneratorWithStability (
1564
1578
"kube_pod_status_scheduled" ,
0 commit comments