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

Fix k8s scheduler compatibility issue #19699

Merged
merged 3 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,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 compatability issue. {pull}19699[19699]
jsoriano marked this conversation as resolved.
Show resolved Hide resolved

*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
22 changes: 22 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,13 @@ func OpMultiplyBuckets(multiplier float64) MetricOption {
}
}

// OpSetSuffix extends the field's name with the given suffix
func OpSetSuffix(suffix string) MetricOption {
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
return opSetSuffix{
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 +386,20 @@ func (o opMultiplyBuckets) Process(field string, value interface{}, labels commo
return field, histogram, labels
}

type opSetSuffix struct {
suffix string
}

// Process will extend the field's name with the given suffix
func (o opSetSuffix) 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