-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prometheus metrics for experiment and trial (#870)
- Loading branch information
1 parent
dd1fb5c
commit 030b691
Showing
6 changed files
with
198 additions
and
0 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
66 changes: 66 additions & 0 deletions
66
pkg/controller.v1alpha3/experiment/util/prometheus_metrics.go
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,66 @@ | ||
/* | ||
Copyright 2019 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 util | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
var ( | ||
experimentsDeletedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_experiment_deleted", | ||
Help: "Counts number of Experiment deleted", | ||
}) | ||
experimentsCreatedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_experiment_created", | ||
Help: "Counts number of Experiment created", | ||
}) | ||
experimentsSucceededCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_experiment_succeeded", | ||
Help: "Counts number of Experiment succeeded", | ||
}) | ||
experimentsFailedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_experiment_failed", | ||
Help: "Counts number of Experiment failed", | ||
}) | ||
) | ||
|
||
func init() { | ||
metrics.Registry.MustRegister( | ||
experimentsDeletedCount, | ||
experimentsCreatedCount, | ||
experimentsSucceededCount, | ||
experimentsFailedCount) | ||
} | ||
|
||
func IncreaseExperimentsDeletedCount() { | ||
experimentsDeletedCount.Inc() | ||
} | ||
|
||
func IncreaseExperimentsCreatedCount() { | ||
experimentsCreatedCount.Inc() | ||
} | ||
|
||
func IncreaseExperimentsSucceededCount() { | ||
experimentsSucceededCount.Inc() | ||
} | ||
|
||
func IncreaseExperimentsFailedCount() { | ||
experimentsFailedCount.Inc() | ||
} |
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,66 @@ | ||
/* | ||
Copyright 2019 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 trial | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
var ( | ||
trialsDeletedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_trial_deleted", | ||
Help: "Counts number of Trial deleted", | ||
}) | ||
trialsCreatedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_trial_created", | ||
Help: "Counts number of Trial created", | ||
}) | ||
trialsSucceededCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_trial_succeeded", | ||
Help: "Counts number of Trial succeeded", | ||
}) | ||
trialsFailedCount = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "katib_trial_failed", | ||
Help: "Counts number of Trial failed", | ||
}) | ||
) | ||
|
||
func init() { | ||
metrics.Registry.MustRegister( | ||
trialsDeletedCount, | ||
trialsCreatedCount, | ||
trialsSucceededCount, | ||
trialsFailedCount) | ||
} | ||
|
||
func IncreaseTrialsDeletedCount() { | ||
trialsDeletedCount.Inc() | ||
} | ||
|
||
func IncreaseTrialsCreatedCount() { | ||
trialsCreatedCount.Inc() | ||
} | ||
|
||
func IncreaseTrialsSucceededCount() { | ||
trialsSucceededCount.Inc() | ||
} | ||
|
||
func IncreaseTrialsFailedCount() { | ||
trialsFailedCount.Inc() | ||
} |
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