Skip to content

Commit

Permalink
Fix k8s scheduler compatibility issue (#19699)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Jul 8, 2020
1 parent ee4882c commit aa60a58
Show file tree
Hide file tree
Showing 10 changed files with 1,451 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix bug incorrect parsing of float numbers as integers in Couchbase module {issue}18949[18949] {pull}19055[19055]
- Fix config example in the perfmon configuration files. {pull}19539[19539]
- Add missing info about the rest of the azure metricsets in the documentation. {pull}19601[19601]
- Fix k8s scheduler compatibility issue. {pull}19699[19699]

*Packetbeat*

Expand Down
20 changes: 19 additions & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25872,7 +25872,7 @@ type: long

--

*`kubernetes.scheduler.scheduling.pod.preemption.victims.count`*::
*`kubernetes.scheduler.scheduling.pod.preemption.victims.bucket.*`*::
+
--
Pod preemption victims
Expand All @@ -25881,6 +25881,24 @@ type: long

--

*`kubernetes.scheduler.scheduling.pod.preemption.victims.sum`*::
+
--
Pod preemption victims sum

type: long

--

*`kubernetes.scheduler.scheduling.pod.preemption.victims.count`*::
+
--
Pod preemption victims count

type: long

--

*`kubernetes.scheduler.scheduling.pod.attempts.count`*::
+
--
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/helper/prometheus/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package prometheus

import (
"fmt"
"math"
"strconv"
"strings"
Expand Down Expand Up @@ -102,6 +103,14 @@ func OpMultiplyBuckets(multiplier float64) MetricOption {
}
}

// OpSetSuffix extends the field's name with the given suffix if the value of the metric
// is numeric (and not histogram or quantile), otherwise does nothing
func OpSetNumericMetricSuffix(suffix string) MetricOption {
return opSetNumericMetricSuffix{
suffix: suffix,
}
}

// Metric directly maps a Prometheus metric to a Metricbeat field
func Metric(field string, options ...MetricOption) MetricMap {
return &commonMetric{
Expand Down Expand Up @@ -378,6 +387,20 @@ func (o opMultiplyBuckets) Process(field string, value interface{}, labels commo
return field, histogram, labels
}

type opSetNumericMetricSuffix struct {
suffix string
}

// Process will extend the field's name with the given suffix
func (o opSetNumericMetricSuffix) Process(field string, value interface{}, labels common.MapStr) (string, interface{}, common.MapStr) {
_, ok := value.(float64)
if !ok {
return field, value, labels
}
field = fmt.Sprintf("%v.%v", field, o.suffix)
return field, value, labels
}

type opUnixTimestampValue struct {
}

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion metricbeat/module/kubernetes/scheduler/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,15 @@
- name: e2e.duration.us.count
type: long
description: End to end scheduling count
- name: pod.preemption.victims.count
- name: pod.preemption.victims.bucket.*
type: long
description: Pod preemption victims
- name: pod.preemption.victims.sum
type: long
description: Pod preemption victims sum
- name: pod.preemption.victims.count
type: long
description: Pod preemption victims count
- name: pod.attempts.count
type: long
description: Pod attempts count
Expand Down
Loading

0 comments on commit aa60a58

Please sign in to comment.