Mikem
November 17, 2021, 1:35pm
1
I have an alert on mysql_global_status_wsrep_cluster_size and it works well. I want to add a second query/alert on ‘wsrep_cluster_status’ but 1) I do not know how to associate this query with a different alert. and 2) I am not sure how to compare a literal string i.e. ‘Primary’ using the functions provided (abs, min, max, etc).
Hi Mikem,
You should create a new alert rule template and use it in a new alert.
Mikem:
I am not sure how to compare a literal string i.e. ‘Primary’ using the functions provided (abs, min, max, etc).
The metric returns number 1 for Primary.
Mikem
November 17, 2021, 10:08pm
3
I only show tabs for Alert Rules and Notification Channels. How do i add/see Alert Rule Templates?
Mikem
November 17, 2021, 10:11pm
4
I found it. Thanks for the help.
Mikem
November 18, 2021, 6:50pm
5
Trying to create an Alert Rule Template but read this on your site -
type (required): PMM currently supports the float type. (More will be available in the future, such as string or bool .)
Does this mean I cannot compare a ‘string’ to a status variable, i.e. ‘wsrep_cluster_status’ ??
I want to create an alert that fires when wsrep_cluster_status <> ‘Primary’
The metric can have values 1 or 0.
}
if bytes.Compare(data, []byte("No")) == 0 || bytes.Compare(data, []byte("OFF")) == 0 {
return 0, true
}
// SHOW SLAVE STATUS Slave_IO_Running can return "Connecting" which is a non-running state.
if bytes.Compare(data, []byte("Connecting")) == 0 {
return 0, true
}
// SHOW GLOBAL STATUS like 'wsrep_cluster_status' can return "Primary" or "non-Primary"/"Disconnected"
if bytes.Compare(data, []byte("Primary")) == 0 {
return 1, true
}
if strings.EqualFold(string(data), "non-Primary") || bytes.Compare(data, []byte("Disconnected")) == 0 {
return 0, true
}
if logNum := logRE.Find(data); logNum != nil {
value, err := strconv.ParseFloat(string(logNum), 64)
return value, err == nil
}
value, err := strconv.ParseFloat(string(data), 64)
return value, err == nil