Skip to content

Commit

Permalink
add metric to prometeus
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Sep 22, 2021
1 parent ad529fa commit 507b693
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/prometheus/client_golang v1.10.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.5.0 // indirect
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
golang.org/x/sys v0.0.0-20210921065528-437939a70204 // indirect
golang.org/x/tools v0.1.6 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ golang.org/x/sys v0.0.0-20210915083310-ed5796bab164 h1:7ZDGnxgHAMw7thfC5bEos0RDA
golang.org/x/sys v0.0.0-20210915083310-ed5796bab164/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 h1:J27LZFQBFoihqXoegpscI10HpjZ7B5WQLLKL2FZXQKw=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210921065528-437939a70204 h1:JJhkWtBuTQKyz2bd5WG9H8iUsJRU3En/KRfN8B2RnDs=
golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
3 changes: 3 additions & 0 deletions metrics/prometheus_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func NewPrometheusMetricSender(registry *prometheus.Registry) *PrometheusMetricS
"opcache_keys_usedKeys",
"opcache_keys_usedScripts",
"opcache_keyHits_misses",
"apcu_memory_free_bytes",
}

for _, gaugeName := range gaugeNames {
Expand All @@ -50,6 +51,7 @@ func (s *PrometheusMetricSender) Send(
nodeStatistics observer.NodeStatistics,
) {
nodeOpcacheStatus := nodeStatistics.OpcacheStatistics
nodeApcuStatus := nodeStatistics.ApcuStatistics

clusterName = strings.ReplaceAll(clusterName, ".", "-")
groupName = strings.ReplaceAll(groupName, ".", "-")
Expand All @@ -64,6 +66,7 @@ func (s *PrometheusMetricSender) Send(
"opcache_keys_usedKeys": nodeOpcacheStatus.Keys.UsedKeys,
"opcache_keys_usedScripts": nodeOpcacheStatus.Keys.UsedScripts,
"opcache_keyHits_misses": nodeOpcacheStatus.KeyHits.Misses,
"apcu_memory_free_bytes": nodeApcuStatus.SmaInfo.AvailMem,
}

for gaugeName, gaugeValue := range gaugeNameValueMap {
Expand Down
4 changes: 2 additions & 2 deletions observer/acpu_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type NodeApcuStatus struct{

type NodeApcuSmaInfo struct {
NumSeg int
SegSize int
AvailMem int
SegSize int // Total memory
AvailMem int // Free memory
//BlockLists [][]struct {
// Size int
// Offset int
Expand Down

0 comments on commit 507b693

Please sign in to comment.