-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add metrics for admission attempts count and duration #233
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,3 @@ spec: | |
- containerPort: 8443 | ||
protocol: TCP | ||
name: https | ||
- name: manager | ||
args: | ||
- "--zap-log-level=2" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
resources: | ||
- monitor.yaml | ||
- role.yaml |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||||||||||
apiVersion: rbac.authorization.k8s.io/v1 | ||||||||||||||
kind: Role | ||||||||||||||
metadata: | ||||||||||||||
name: prometheus-k8s | ||||||||||||||
namespace: system | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we create There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, this is where kustomize works, refer to kueue/config/default/kustomization.yaml Lines 4 to 9 in a4703d3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Thanks |
||||||||||||||
rules: | ||||||||||||||
- apiGroups: | ||||||||||||||
- "" | ||||||||||||||
resources: | ||||||||||||||
- services | ||||||||||||||
- endpoints | ||||||||||||||
- pods | ||||||||||||||
verbs: | ||||||||||||||
- get | ||||||||||||||
- list | ||||||||||||||
- watch | ||||||||||||||
- apiGroups: | ||||||||||||||
- extensions | ||||||||||||||
resources: | ||||||||||||||
- ingresses | ||||||||||||||
verbs: | ||||||||||||||
- get | ||||||||||||||
- list | ||||||||||||||
- watch | ||||||||||||||
- apiGroups: | ||||||||||||||
- networking.k8s.io | ||||||||||||||
resources: | ||||||||||||||
- ingresses | ||||||||||||||
verbs: | ||||||||||||||
- get | ||||||||||||||
- list | ||||||||||||||
- watch | ||||||||||||||
--- | ||||||||||||||
apiVersion: rbac.authorization.k8s.io/v1 | ||||||||||||||
kind: RoleBinding | ||||||||||||||
metadata: | ||||||||||||||
name: prometheus-k8s | ||||||||||||||
namespace: system | ||||||||||||||
roleRef: | ||||||||||||||
apiGroup: rbac.authorization.k8s.io | ||||||||||||||
kind: Role | ||||||||||||||
name: prometheus-k8s | ||||||||||||||
subjects: | ||||||||||||||
- kind: ServiceAccount | ||||||||||||||
name: prometheus-k8s | ||||||||||||||
namespace: monitoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2022 The Kubernetes 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 ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
type AdmissionResult string | ||
|
||
const ( | ||
subsystemName = "kueue" | ||
|
||
SuccessAdmissionResult AdmissionResult = "success" | ||
InadmissibleAdmissionResult AdmissionResult = "inadmissible" | ||
) | ||
|
||
var ( | ||
admissionAttempts = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Subsystem: subsystemName, | ||
Name: "admission_attempts_total", | ||
Help: "Number of attempts to admit one or more workloads, broken down by result. `success` means that at least one workload was admitted, `inadmissible` means that no workload was admitted.", | ||
}, []string{"result"}, | ||
) | ||
|
||
admissionAttemptLatency = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Subsystem: subsystemName, | ||
Name: "admission_attempt_duration_seconds", | ||
Help: "Latency of an admission attempt, broken down by result.", | ||
}, []string{"result"}, | ||
) | ||
) | ||
|
||
func AdmissionAttempt(result AdmissionResult, duration time.Duration) { | ||
admissionAttempts.WithLabelValues(string(result)).Inc() | ||
admissionAttemptLatency.WithLabelValues(string(result)).Observe(duration.Seconds()) | ||
} | ||
|
||
func init() { | ||
metrics.Registry.MustRegister( | ||
admissionAttempts, | ||
admissionAttemptLatency, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you decide to remove this? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It initially had flags related to metrics, but they are all in the component config now. There is no point of keeping it in the patch.