Skip to content

Commit

Permalink
fix: tidy up missing metrics for exporter (OpenAtomFoundation#1753)
Browse files Browse the repository at this point in the history
tidy up missing metrics for exporter

Fixes: OpenAtomFoundation#1744

Signed-off-by: yaoyinnan <[email protected]>
  • Loading branch information
yaoyinnan authored Jul 18, 2023
1 parent 4821991 commit 294e702
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 811 deletions.
Binary file modified tools/pika_exporter/contrib/base_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/pika_exporter/contrib/replication.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/pika_exporter/contrib/rocksdb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 1 addition & 12 deletions tools/pika_exporter/exporter/metrics/binlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ func init() {
}

var collectBinlogMetrics = map[string]MetricConfig{
"binlog_log_size": {
Parser: &normalParser{},
MetricMeta: &MetaData{
Name: "log_size",
Help: "pika serve instance total binlog size in bytes",
Type: metricTypeGauge,
Labels: []string{LabelNameAddr, LabelNameAlias},
ValueName: "log_size",
},
},

"binlog_<3.1.0": {
Parser: &versionMatchParser{
verC: mustNewVersionConstraint(`<3.1.0`),
Expand Down Expand Up @@ -85,7 +74,7 @@ var collectBinlogMetrics = map[string]MetricConfig{
"consensus_last_log": {
Parser: Parsers{
&versionMatchParser{
verC: mustNewVersionConstraint(`>3.4.0`),
verC: mustNewVersionConstraint(`>3.4.0,<3.5.0`),
Parser: &regexParser{
name: "consensus_last_log",
reg: regexp.MustCompile(`(?P<consensus>consensus)\s*last_log=(?P<consensus_last_log>[^\s\r\n]*)`),
Expand Down
10 changes: 10 additions & 0 deletions tools/pika_exporter/exporter/metrics/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ var collectDataMetrics = map[string]MetricConfig{
ValueName: "db_size",
},
},
"log_size": {
Parser: &normalParser{},
MetricMeta: &MetaData{
Name: "log_size",
Help: "pika serve instance total log size in bytes",
Type: metricTypeGauge,
Labels: []string{LabelNameAddr, LabelNameAlias},
ValueName: "log_size",
},
},
"used_memory": {
Parser: &normalParser{},
MetricMeta: &MetaData{
Expand Down
12 changes: 6 additions & 6 deletions tools/pika_exporter/exporter/metrics/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var collectReplicationMetrics = map[string]MetricConfig{
Name: "slave_lag",
Help: "pika serve instance slave's slot binlog lag",
Type: metricTypeGauge,
Labels: []string{LabelNameAddr, LabelNameAlias, "slave_conn_fd", "slave_ip", "slave_port", "slot"},
Labels: []string{LabelNameAddr, LabelNameAlias, "slave_ip", "slave_port", "slave_conn_fd", "db"},
ValueName: "slave_lag",
},
},
Expand All @@ -115,7 +115,7 @@ var collectReplicationMetrics = map[string]MetricConfig{
},
Parser: Parsers{
&versionMatchParser{
verC: mustNewVersionConstraint(`>=3.4.0`),
verC: mustNewVersionConstraint(`>=3.4.0,<3.1.0`),
Parser: &regexParser{
name: "master_sharding_slave_info_slave_lag",
reg: regexp.MustCompile(`slave\d+:ip=(?P<slave_ip>[\d.]+),port=(?P<slave_port>[\d.]+),` +
Expand All @@ -129,7 +129,7 @@ var collectReplicationMetrics = map[string]MetricConfig{
},
},
&versionMatchParser{
verC: mustNewVersionConstraint(`>=3.4.0`),
verC: mustNewVersionConstraint(`>=3.4.0,<3.5.0`),
Parser: &regexParser{
name: "master_sharding_slave_info_slave_lag",
reg: regexp.MustCompile(`db_repl_state:(?P<slave_lag>[^\r\n]*)`),
Expand Down Expand Up @@ -222,14 +222,14 @@ var collectReplicationMetrics = map[string]MetricConfig{
},
},

"sharding_slave_info>=3.4.0": {
"sharding_slave_info>=3.4.x,<3.5.0": {
Parser: &keyMatchParser{
matchers: map[string]Matcher{
"role": &equalMatcher{v: "slave"},
"instance-mode": &equalMatcher{v: "sharding"},
},
Parser: &versionMatchParser{
verC: mustNewVersionConstraint(`>=3.4.0`),
verC: mustNewVersionConstraint(`>=3.4.x,<3.5.0`),
Parser: &normalParser{},
},
},
Expand All @@ -242,7 +242,7 @@ var collectReplicationMetrics = map[string]MetricConfig{
},
},

"double_master_info": {
"double_master_info<=3.4.2": {
Parser: &keyMatchParser{
matchers: map[string]Matcher{
"role": &equalMatcher{v: "master"},
Expand Down
2 changes: 2 additions & 0 deletions tools/pika_exporter/exporter/metrics/rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ var collectRocksDBMetrics = map[string]MetricConfig{
"size_all_mem_tables": {
Parser: &regexParser{
name: "size_all_mem_tables",
// TODO: need fix size_all_mem_tables contains wrong data type starting with cur
// issue: https://github.com/OpenAtomFoundation/pika/issues/1752
reg: regexp.MustCompile(`(?P<data_type>\w+)_.*?size_all_mem_tables:(?P<size_all_mem_tables>\d+)`),
Parser: &normalParser{},
},
Expand Down
2 changes: 1 addition & 1 deletion tools/pika_exporter/exporter/metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var collectServerMetrics = map[string]MetricConfig{
Name: "server_info",
Help: "pika serve instance info",
Type: metricTypeGauge,
Labels: []string{LabelNameAddr, LabelNameAlias, "process_id", "tcp_port", "config_file", "server_id", "role"},
Labels: []string{LabelNameAddr, LabelNameAlias, "process_id", "tcp_port", "config_file", "server_id", "role", "run_id"},
},
},
"uptime_in_seconds": {
Expand Down
Loading

0 comments on commit 294e702

Please sign in to comment.