-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Starnop <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,493 additions
and
63 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,102 @@ | ||
package metrics | ||
|
||
import ( | ||
"sync" | ||
|
||
util_metrics "github.com/alibaba/pouch/pkg/utils/metrics" | ||
|
||
"github.com/grpc-ecosystem/go-grpc-prometheus" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
func init() { | ||
// Register prometheus metrics. | ||
Register() | ||
} | ||
|
||
const ( | ||
subsystemCRI = "cri" | ||
) | ||
|
||
var ( | ||
// GRPCMetrics create some standard server metrics. | ||
GRPCMetrics = grpc_prometheus.NewServerMetrics() | ||
|
||
// PodActionsCounter records the number of pod operations. | ||
PodActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "pod_actions_counter", "The number of pod operations", "action") | ||
|
||
// PodSuccessActionsCounter records the number of pod success operations. | ||
PodSuccessActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "pod_success_actions_counter", "The number of pod success operations", "action") | ||
|
||
// PodActionsTimer records the time cost of each pod action. | ||
PodActionsTimer = util_metrics.NewLabelTimer(subsystemCRI, "pod_actions", "The number of seconds it takes to process each pod action", "action") | ||
|
||
// ContainerActionsCounter records the number of container operations. | ||
ContainerActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "container_actions_counter", "The number of container operations", "action") | ||
|
||
// ContainerSuccessActionsCounter records the number of container success operations. | ||
ContainerSuccessActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "container_success_actions_counter", "The number of container success operations", "action") | ||
|
||
// ContainerActionsTimer records the time cost of each container action. | ||
ContainerActionsTimer = util_metrics.NewLabelTimer(subsystemCRI, "container_actions", "The number of seconds it takes to process each container action", "action") | ||
|
||
// ImagePullSummary records the summary of pulling image latency. | ||
ImagePullSummary = util_metrics.NewLabelSummary(subsystemCRI, "image_pull_latency_microseconds", "Latency in microseconds to pull a image.", "image") | ||
|
||
// ImageActionsCounter records the number of image operations. | ||
ImageActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "image_actions_counter", "The number of image operations", "action") | ||
|
||
// ImageSuccessActionsCounter the number of image success operations. | ||
ImageSuccessActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "image_success_actions_counter", "The number of image success operations", "action") | ||
|
||
// ImageActionsTimer records the time cost of each image action. | ||
ImageActionsTimer = util_metrics.NewLabelTimer(subsystemCRI, "image_actions", "The number of seconds it takes to process each image action", "action") | ||
|
||
// VolumeActionsCounter records the number of volume operations. | ||
VolumeActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "volume_actions_counter", "The number of volume operations", "action") | ||
|
||
// VolumeSuccessActionsCounter the number of volume success operations. | ||
VolumeSuccessActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "volume_success_actions_counter", "The number of volume success operations", "action") | ||
|
||
// VolumeActionsTimer records the time cost of each volume action. | ||
VolumeActionsTimer = util_metrics.NewLabelTimer(subsystemCRI, "volume_actions", "The number of seconds it takes to process each volume action", "action") | ||
|
||
// RuntimeActionsCounter records the number of runtime operations. | ||
RuntimeActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "runtime_actions_counter", "The number of runtime operations", "action") | ||
|
||
// RuntimeSuccessActionsCounter the number of runtime success operations. | ||
RuntimeSuccessActionsCounter = util_metrics.NewLabelCounter(subsystemCRI, "runtime_success_actions_counter", "The number of runtime success operations", "action") | ||
|
||
// RuntimeActionsTimer records the time cost of each runtime action. | ||
RuntimeActionsTimer = util_metrics.NewLabelTimer(subsystemCRI, "runtime_actions", "The number of seconds it takes to process each runtime action", "action") | ||
) | ||
|
||
var registerMetrics sync.Once | ||
|
||
// Register all metrics. | ||
func Register() { | ||
registerMetrics.Do(func() { | ||
// EnableHandlingTimeHistogram turns on recording of handling time | ||
// of RPCs. Histogram metrics can be very expensive for Prometheus | ||
// to retain and query. | ||
GRPCMetrics.EnableHandlingTimeHistogram() | ||
|
||
prometheus.MustRegister(GRPCMetrics) | ||
prometheus.MustRegister(PodActionsCounter) | ||
prometheus.MustRegister(PodSuccessActionsCounter) | ||
prometheus.MustRegister(PodActionsTimer) | ||
prometheus.MustRegister(ContainerActionsCounter) | ||
prometheus.MustRegister(ContainerSuccessActionsCounter) | ||
prometheus.MustRegister(ContainerActionsTimer) | ||
prometheus.MustRegister(ImagePullSummary) | ||
prometheus.MustRegister(ImageActionsCounter) | ||
prometheus.MustRegister(ImageSuccessActionsCounter) | ||
prometheus.MustRegister(ImageActionsTimer) | ||
prometheus.MustRegister(VolumeActionsCounter) | ||
prometheus.MustRegister(VolumeSuccessActionsCounter) | ||
prometheus.MustRegister(VolumeActionsTimer) | ||
prometheus.MustRegister(RuntimeActionsCounter) | ||
prometheus.MustRegister(RuntimeSuccessActionsCounter) | ||
prometheus.MustRegister(RuntimeActionsTimer) | ||
}) | ||
} |
Oops, something went wrong.