Skip to content

collector/binlog: parse the binlog file number after the last dot - #1095

Merged
ArthurSens merged 1 commit into
prometheus:mainfrom
LemonCondor:binlog-file-number-dotted-basename
Oct 20, 2026
Merged

ArthurSens merged 1 commit into
prometheus:mainfrom
LemonCondor:binlog-file-number-dotted-basename

Conversation

@LemonCondor

Copy link
Copy Markdown
Contributor

mysql_binlog_file_number is computed from strings.Split(filename, ".")[1], i.e. the part after the first dot of the last binary log file name. If the binary log base name contains a dot (e.g. log_bin=db1.example-bin, giving files like db1.example-bin.000042), that part is example-bin, ParseFloat fails, the error is discarded, and the metric is exported as 0.

This takes the extension after the last dot instead (path.Ext), which is the sequence number MySQL appends. An empty file name now also yields 0 instead of panicking on [1].

Tests: added TestScrapeBinlogSizeDottedBasename (reports 0 instead of 42 before this change, passes after); go test ./... passes, gofmt and go vet ./collector/ are clean.

mysql_binlog_file_number took the part after the first dot of the last
binlog file name. When the binary log base name contains a dot (for
example db1.example-bin.000042), that part is not a number, the parse
error is ignored and the metric is reported as 0. Use the extension
after the last dot instead.

Signed-off-by: Guillaume Marty <[email protected]>

@macabu macabu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ArthurSens ArthurSens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@ArthurSens
ArthurSens merged commit c9d58d4 into prometheus:main Oct 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants