Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableMgrAlert:Return different values according to different states … #621

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions collector/perf_schema_replication_group_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (ScrapePerfReplicationGroupMembers) Scrape(ctx context.Context, db *sql.DB,
for i := range scanArgs {
scanArgs[i] = &sql.RawBytes{}
}

memberStateValue := float64(0)
for perfReplicationGroupMembersRows.Next() {
if err := perfReplicationGroupMembersRows.Scan(scanArgs...); err != nil {
return err
Expand All @@ -71,6 +71,9 @@ func (ScrapePerfReplicationGroupMembers) Scrape(ctx context.Context, db *sql.DB,
for i, columnName := range columnNames {
labelNames[i] = strings.ToLower(columnName)
values[i] = string(*scanArgs[i].(*sql.RawBytes))
if labelNames[i] == "member_state" && values[i] == "ONLINE" {
memberStateValue = 1
}
}

var performanceSchemaReplicationGroupMembersMemberDesc = prometheus.NewDesc(
Expand All @@ -82,7 +85,7 @@ func (ScrapePerfReplicationGroupMembers) Scrape(ctx context.Context, db *sql.DB,
)

ch <- prometheus.MustNewConstMetric(performanceSchemaReplicationGroupMembersMemberDesc,
prometheus.GaugeValue, 1, values...)
prometheus.GaugeValue, memberStateValue, values...)
}
return nil

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.