Skip to content

Commit

Permalink
Removed the value label variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
janzantinge committed Nov 14, 2019
1 parent a0c63d5 commit 12718da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/horizontalpodautoscaler-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| kube_hpa_metadata_generation | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; | STABLE |
| kube_hpa_spec_max_replicas | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; | STABLE |
| kube_hpa_spec_min_replicas | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; | STABLE |
| kube_hpa_spec_target_metric | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; <br> `metric_name`=&lt;metric-name&gt; <br> `metric_target_type`=&lt;value\|utilization\|average&gt; | EXPERIMENTAL |
| kube_hpa_spec_target_metric | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; <br> `metric_name`=&lt;metric-name&gt; <br> `metric_target_type`=&lt;value\|average&gt; | EXPERIMENTAL |
| kube_hpa_status_condition | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; <br> `condition`=&lt;hpa-condition&gt; <br> `status`=&lt;true\|false\|unknown&gt; | STABLE |
| kube_hpa_status_current_replicas | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; | STABLE |
| kube_hpa_status_currentmetrics_average_utilization | Gauge | `hpa`=&lt;hpa-name&gt; <br> `namespace`=&lt;hpa-namespace&gt; | EXPERIMENTAL |
Expand Down
6 changes: 2 additions & 4 deletions internal/store/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ var (
for _, m := range a.Spec.Metrics {
var metricName string
var value, average int64
valueLabel := "value"
var valueOk, averageOk bool

switch m.Type {
Expand All @@ -107,15 +106,14 @@ var (

value = int64(*m.Resource.TargetAverageUtilization)
valueOk = true
valueLabel = "utilization"

if m.Resource.TargetAverageValue != nil {
average, averageOk = m.Resource.TargetAverageValue.AsInt64()
}
case autoscaling.ExternalMetricSourceType:
metricName = m.External.MetricName

// The TargetValue and TargetAverageValue are mutually exclusive
// The TargetValue and TargetAverageValue fields are mutually exclusive
if m.External.TargetValue != nil {
value, valueOk = m.External.TargetValue.AsInt64()
}
Expand All @@ -130,7 +128,7 @@ var (
if valueOk {
targets = append(targets, &metric.Metric{
LabelKeys: targetMetricLabels,
LabelValues: []string{metricName, valueLabel},
LabelValues: []string{metricName, "value"},
Value: float64(value),
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/store/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func TestHPAStore(t *testing.T) {
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="hits",metric_target_type="value"} 10
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="hits",metric_target_type="average"} 12
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="transactions_processed",metric_target_type="average"} 33
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="cpu",metric_target_type="utilization"} 80
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="memory",metric_target_type="utilization"} 80
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="cpu",metric_target_type="value"} 80
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="memory",metric_target_type="value"} 80
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="memory",metric_target_type="average"} 819200
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="sqs_jobs",metric_target_type="value"} 30
kube_hpa_spec_target_metric{hpa="hpa1",namespace="ns1",metric_name="events",metric_target_type="average"} 30
Expand Down

0 comments on commit 12718da

Please sign in to comment.