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

allow exporting dates as timestamps grom GLOBAL STATUS #561

Merged
merged 4 commits into from
Jul 20, 2021
Merged
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: 7 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
)
Expand Down Expand Up @@ -58,6 +59,12 @@ func parseStatus(data sql.RawBytes) (float64, bool) {
case "non-primary", "disconnected":
return 0, true
}
if ts, err := time.Parse("Jan 02 15:04:05 2006 MST", string(data)); err == nil {
return float64(ts.Unix()), true
}
if ts, err := time.Parse("2006-01-02 15:04:05", string(data)); err == nil {
return float64(ts.Unix()), true
}
if logNum := logRE.Find(data); logNum != nil {
value, err := strconv.ParseFloat(string(logNum), 64)
return value, err == nil
Expand Down