Repository navigation
collector/binlog: parse the binlog file number after the last dot - #1095
Merged
ArthurSens merged 1 commit intoOct 20, 2026
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mysql_binlog_file_numberis computed fromstrings.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 likedb1.example-bin.000042), that part isexample-bin,ParseFloatfails, the error is discarded, and the metric is exported as0.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,gofmtandgo vet ./collector/are clean.