-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kubernetes apiserver metricset (#7059)
This new metricset gathers metrics from Kubernetes API servers, giving visibility on number of requests and latency. This change adds support for `summary` and `histogram` metric type to our Prometheus helper, histogram is used to retrieve latency info. I also simplified the process of creating a new metricset based on this helper, to the point you only need [this](https://github.com/exekias/beats/blob/5f4568208ac273d9b759343b22f783184951a477/metricbeat/module/kubernetes/apiserver/apiserver.go) to create it and [this](https://github.com/exekias/beats/blob/5f4568208ac273d9b759343b22f783184951a477/metricbeat/module/kubernetes/apiserver/apiserver_test.go) to test it.
- Loading branch information
Showing
20 changed files
with
20,375 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package prometheus | ||
|
||
import ( | ||
"github.com/elastic/beats/metricbeat/mb" | ||
"github.com/elastic/beats/metricbeat/mb/parse" | ||
) | ||
|
||
const ( | ||
defaultScheme = "http" | ||
defaultPath = "/metrics" | ||
) | ||
|
||
var ( | ||
// HostParser validates Prometheus URLs | ||
HostParser = parse.URLHostParserBuilder{ | ||
DefaultScheme: defaultScheme, | ||
DefaultPath: defaultPath, | ||
}.Build() | ||
) | ||
|
||
// MetricSetBuilder returns a builder function for a new Prometheus metricset using the given mapping | ||
func MetricSetBuilder(mapping *MetricsMapping) func(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
return func(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
prometheus, err := NewPrometheusClient(base) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &prometheusMetricSet{ | ||
BaseMetricSet: base, | ||
prometheus: prometheus, | ||
mapping: mapping, | ||
}, nil | ||
} | ||
} | ||
|
||
type prometheusMetricSet struct { | ||
mb.BaseMetricSet | ||
prometheus Prometheus | ||
mapping *MetricsMapping | ||
} | ||
|
||
func (m *prometheusMetricSet) Fetch(r mb.ReporterV2) { | ||
m.prometheus.ReportProcessedMetrics(m.mapping, r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.