forked from OpenAtomFoundation/pikiwidb
-
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.
feat: cache metrics (OpenAtomFoundation#2318)
* cache metrics
- Loading branch information
1 parent
c1917c7
commit 5276adb
Showing
5 changed files
with
96 additions
and
5 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,87 @@ | ||
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved. | ||
// This source code is licensed under the BSD-style license found in the | ||
// LICENSE file in the root directory of this source tree. An additional grant | ||
// of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
package metrics | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
func RegisterCache() { | ||
Register(collectCacheMetrics) | ||
} | ||
|
||
var collectCacheMetrics = map[string]MetricConfig{ | ||
"cache_status": { | ||
Parser: &normalParser{}, | ||
MetricMeta: &MetaData{ | ||
Name: "cache_status", | ||
Help: "pika serve instance cache status", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "cache_status", | ||
}, | ||
}, | ||
"cache_db_num": { | ||
Parser: &normalParser{}, | ||
MetricMeta: &MetaData{ | ||
Name: "cache_db_num", | ||
Help: "pika serve instance cache number", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "cache_db_num", | ||
}, | ||
}, | ||
"cache_memory": { | ||
Parser: &normalParser{}, | ||
MetricMeta: &MetaData{ | ||
Name: "cache_memory", | ||
Help: "pika serve instance cache memory usage", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "cache_memory", | ||
}, | ||
}, | ||
"hits_per_sec": { | ||
Parser: &normalParser{}, | ||
MetricMeta: &MetaData{ | ||
Name: "hits_per_sec", | ||
Help: "pika serve instance cache hit count per second ", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "hits_per_sec", | ||
}, | ||
}, | ||
"hitratio_per_second": { | ||
Parser: ®exParser{ | ||
name: "hitratio_per_sec", | ||
reg: regexp.MustCompile(`^(?P<hitratio_per_sec>\d+)%$`), | ||
Parser: &normalParser{}, | ||
source: "hitratio_per_sec", | ||
}, | ||
MetricMeta: &MetaData{ | ||
Name: "hitratio_per_sec", | ||
Help: "pika serve instance cache hit rate per second", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "hitratio_per_sec", | ||
}, | ||
}, | ||
"hitratio": { | ||
Parser: ®exParser{ | ||
name: "hitratio_per_sec", | ||
reg: regexp.MustCompile(`^(?P<hitratio_all>\d+)%$`), | ||
Parser: &normalParser{}, | ||
source: "hitratio_all", | ||
}, | ||
MetricMeta: &MetaData{ | ||
Name: "hitratio_all", | ||
Help: "pika serve instance cache hit rate", | ||
Type: metricTypeGauge, | ||
Labels: []string{LabelNameAddr, LabelNameAlias}, | ||
ValueName: "hitratio_all", | ||
}, | ||
}, | ||
} |
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