forked from koordinator-sh/koordinator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: seperater metrics as internal and external for slo-controlle…
…r and koordlet (koordinator-sh#1807) Signed-off-by: 佑祎 <zzw261520@alibaba-inc.com>
- Loading branch information
1 parent
cd2c859
commit b69eddc
Showing
11 changed files
with
269 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metrics | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
const ( | ||
ExternalHTTPPath = "/external-metrics" | ||
) | ||
|
||
var ( | ||
// ExternalRegistry register metrics for users such as PMU or extended resources settings | ||
ExternalRegistry = prometheus.NewRegistry() | ||
) | ||
|
||
func ExternalMustRegister(metrics ...prometheus.Collector) { | ||
ExternalRegistry.MustRegister(metrics...) | ||
} | ||
|
||
func init() { | ||
ExternalMustRegister(ResourceSummaryCollectors...) | ||
ExternalMustRegister(CPICollectors...) | ||
ExternalMustRegister(PSICollectors...) | ||
} |
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 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"k8s.io/component-base/metrics/legacyregistry" | ||
) | ||
|
||
const ( | ||
InternalHTTPPath = "/internal-metrics" | ||
) | ||
|
||
var ( | ||
// InternalRegistry only register metrics of koordlet itself for performance and functional monitor | ||
// TODO consider using k8s.io/component-base/metrics to replace github.com/prometheus/client_golang/prometheus | ||
InternalRegistry = legacyregistry.DefaultGatherer | ||
) | ||
|
||
func internalMustRegister(metrics ...prometheus.Collector) { | ||
legacyregistry.RawMustRegister(metrics...) | ||
} | ||
|
||
func init() { | ||
internalMustRegister(CommonCollectors...) | ||
internalMustRegister(CPUSuppressCollector...) | ||
internalMustRegister(CPUBurstCollector...) | ||
internalMustRegister(PredictionCollectors...) | ||
internalMustRegister(CoreSchedCollector...) | ||
} |
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,45 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
dto "github.com/prometheus/client_model/go" | ||
) | ||
|
||
var _ prometheus.Gatherer = &mergedGather{} | ||
|
||
type mergedGather struct { | ||
gathers []prometheus.Gatherer | ||
} | ||
|
||
// MergedGatherFunc returns a Gatherer that merges the results of multiple Gatherers | ||
func MergedGatherFunc(g ...prometheus.Gatherer) prometheus.Gatherer { | ||
return &mergedGather{gathers: g} | ||
} | ||
|
||
func (m *mergedGather) Gather() ([]*dto.MetricFamily, error) { | ||
result := make([]*dto.MetricFamily, 0) | ||
for _, g := range m.gathers { | ||
if metrics, err := g.Gather(); err != nil { | ||
return result, err | ||
} else { | ||
result = append(result, metrics...) | ||
} | ||
} | ||
return result, nil | ||
} |
Oops, something went wrong.