Skip to content

Commit

Permalink
Merge pull request #9 from percona/myrocks
Browse files Browse the repository at this point in the history
Add notes about global status
  • Loading branch information
AlekSi authored Sep 12, 2017
2 parents a3a4745 + 8cc8790 commit 6169494
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
45 changes: 23 additions & 22 deletions collector/engine_rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,44 @@ const (
var (
rocksDBCounter = regexp.MustCompile(`^([a-z\.]+) COUNT : (\d+)$`)

// Map known counters to descriptions. Unknown counters will be skipped.
// Map known SHOW ENGINE ROCKSDB STATUS counters to the metric descriptions.
// Unknown counters will be skipped.
engineRocksDBStatusTypes = map[string]*prometheus.Desc{
"rocksdb.block.cache.miss": newDesc(rocksDB, "block_cache_miss", "rocksdb.block.cache.miss"),
"rocksdb.block.cache.hit": newDesc(rocksDB, "block_cache_hit", "rocksdb.block.cache.hit"),
"rocksdb.block.cache.add": newDesc(rocksDB, "block_cache_add", "rocksdb.block.cache.add"),
"rocksdb.block.cache.add.failures": newDesc(rocksDB, "block_cache_add_failures", "rocksdb.block.cache.add.failures"),
"rocksdb.block.cache.add.failures": newDesc(rocksDB, "block_cache_add_failures", "rocksdb.block.cache.add.failures"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.data.miss": newDesc(rocksDB, "block_cache_data_miss", "rocksdb.block.cache.data.miss"),
"rocksdb.block.cache.data.hit": newDesc(rocksDB, "block_cache_data_hit", "rocksdb.block.cache.data.hit"),
"rocksdb.block.cache.data.add": newDesc(rocksDB, "block_cache_data_add", "rocksdb.block.cache.data.add"),
"rocksdb.block.cache.data.add": newDesc(rocksDB, "block_cache_data_add", "rocksdb.block.cache.data.add"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.index.miss": newDesc(rocksDB, "block_cache_index_miss", "rocksdb.block.cache.index.miss"),
"rocksdb.block.cache.index.hit": newDesc(rocksDB, "block_cache_index_hit", "rocksdb.block.cache.index.hit"),
"rocksdb.block.cache.index.add": newDesc(rocksDB, "block_cache_index_add", "rocksdb.block.cache.index.add"),
"rocksdb.block.cache.index.add": newDesc(rocksDB, "block_cache_index_add", "rocksdb.block.cache.index.add"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.index.bytes.insert": newDesc(rocksDB, "block_cache_index_bytes_insert", "rocksdb.block.cache.index.bytes.insert"),
"rocksdb.block.cache.index.bytes.evict": newDesc(rocksDB, "block_cache_index_bytes_evict", "rocksdb.block.cache.index.bytes.evict"),
"rocksdb.block.cache.index.bytes.insert": newDesc(rocksDB, "block_cache_index_bytes_insert", "rocksdb.block.cache.index.bytes.insert"), // not present in SHOW GLOBAL STATUS
"rocksdb.block.cache.index.bytes.evict": newDesc(rocksDB, "block_cache_index_bytes_evict", "rocksdb.block.cache.index.bytes.evict"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.filter.miss": newDesc(rocksDB, "block_cache_filter_miss", "rocksdb.block.cache.filter.miss"),
"rocksdb.block.cache.filter.hit": newDesc(rocksDB, "block_cache_filter_hit", "rocksdb.block.cache.filter.hit"),
"rocksdb.block.cache.filter.add": newDesc(rocksDB, "block_cache_filter_add", "rocksdb.block.cache.filter.add"),
"rocksdb.block.cache.filter.add": newDesc(rocksDB, "block_cache_filter_add", "rocksdb.block.cache.filter.add"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.filter.bytes.insert": newDesc(rocksDB, "block_cache_filter_bytes_insert", "rocksdb.block.cache.filter.bytes.insert"),
"rocksdb.block.cache.filter.bytes.evict": newDesc(rocksDB, "block_cache_filter_bytes_evict", "rocksdb.block.cache.filter.bytes.evict"),
"rocksdb.block.cache.filter.bytes.insert": newDesc(rocksDB, "block_cache_filter_bytes_insert", "rocksdb.block.cache.filter.bytes.insert"), // not present in SHOW GLOBAL STATUS
"rocksdb.block.cache.filter.bytes.evict": newDesc(rocksDB, "block_cache_filter_bytes_evict", "rocksdb.block.cache.filter.bytes.evict"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.bytes.read": newDesc(rocksDB, "block_cache_bytes_read", "rocksdb.block.cache.bytes.read"),
"rocksdb.block.cache.bytes.write": newDesc(rocksDB, "block_cache_bytes_write", "rocksdb.block.cache.bytes.write"),
"rocksdb.block.cache.bytes.read": newDesc(rocksDB, "block_cache_bytes_read", "rocksdb.block.cache.bytes.read"), // not present in SHOW GLOBAL STATUS
"rocksdb.block.cache.bytes.write": newDesc(rocksDB, "block_cache_bytes_write", "rocksdb.block.cache.bytes.write"), // not present in SHOW GLOBAL STATUS

"rocksdb.block.cache.data.bytes.insert": newDesc(rocksDB, "block_cache_data_bytes_insert", "rocksdb.block.cache.data.bytes.insert"),
"rocksdb.block.cache.data.bytes.insert": newDesc(rocksDB, "block_cache_data_bytes_insert", "rocksdb.block.cache.data.bytes.insert"), // not present in SHOW GLOBAL STATUS

"rocksdb.bloom.filter.useful": newDesc(rocksDB, "bloom_filter_useful", "rocksdb.bloom.filter.useful"),

"rocksdb.memtable.miss": newDesc(rocksDB, "memtable_miss", "rocksdb.memtable.miss"),
"rocksdb.memtable.hit": newDesc(rocksDB, "memtable_hit", "rocksdb.memtable.hit"),

"rocksdb.l0.hit": newDesc(rocksDB, "l0_hit", "rocksdb.l0.hit"),
"rocksdb.l1.hit": newDesc(rocksDB, "l1_hit", "rocksdb.l1.hit"),
"rocksdb.l0.hit": newDesc(rocksDB, "l0_hit", "rocksdb.l0.hit"), // not present in SHOW GLOBAL STATUS
"rocksdb.l1.hit": newDesc(rocksDB, "l1_hit", "rocksdb.l1.hit"), // not present in SHOW GLOBAL STATUS

"rocksdb.number.keys.read": newDesc(rocksDB, "number_keys_read", "rocksdb.number.keys.read"),
"rocksdb.number.keys.written": newDesc(rocksDB, "number_keys_written", "rocksdb.number.keys.written"),
Expand All @@ -68,14 +69,14 @@ var (
"rocksdb.bytes.read": newDesc(rocksDB, "bytes_read", "rocksdb.bytes.read"),
"rocksdb.bytes.written": newDesc(rocksDB, "bytes_written", "rocksdb.bytes.written"),

"rocksdb.number.db.seek": newDesc(rocksDB, "number_db_seek", "rocksdb.number.db.seek"),
"rocksdb.number.db.seek.found": newDesc(rocksDB, "number_db_seek_found", "rocksdb.number.db.seek.found"),
"rocksdb.number.db.next": newDesc(rocksDB, "number_db_next", "rocksdb.number.db.next"),
"rocksdb.number.db.next.found": newDesc(rocksDB, "number_db_next_found", "rocksdb.number.db.next.found"),
"rocksdb.number.db.prev": newDesc(rocksDB, "number_db_prev", "rocksdb.number.db.prev"),
"rocksdb.number.db.prev.found": newDesc(rocksDB, "number_db_prev_found", "rocksdb.number.db.prev.found"),
"rocksdb.number.db.seek": newDesc(rocksDB, "number_db_seek", "rocksdb.number.db.seek"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.db.seek.found": newDesc(rocksDB, "number_db_seek_found", "rocksdb.number.db.seek.found"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.db.next": newDesc(rocksDB, "number_db_next", "rocksdb.number.db.next"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.db.next.found": newDesc(rocksDB, "number_db_next_found", "rocksdb.number.db.next.found"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.db.prev": newDesc(rocksDB, "number_db_prev", "rocksdb.number.db.prev"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.db.prev.found": newDesc(rocksDB, "number_db_prev_found", "rocksdb.number.db.prev.found"), // not present in SHOW GLOBAL STATUS

"rocksdb.db.iter.bytes.read": newDesc(rocksDB, "db_iter_bytes_read", "rocksdb.db.iter.bytes.read"),
"rocksdb.db.iter.bytes.read": newDesc(rocksDB, "db_iter_bytes_read", "rocksdb.db.iter.bytes.read"), // not present in SHOW GLOBAL STATUS
"rocksdb.number.reseeks.iteration": newDesc(rocksDB, "number_reseeks_iteration", "rocksdb.number.reseeks.iteration"),

"rocksdb.wal.synced": newDesc(rocksDB, "wal_synced", "rocksdb.wal.synced"),
Expand All @@ -87,7 +88,7 @@ var (

"rocksdb.write.self": newDesc(rocksDB, "write_self", "rocksdb.write.self"),
"rocksdb.write.other": newDesc(rocksDB, "write_other", "rocksdb.write.other"),
"rocksdb.write.timeout": newDesc(rocksDB, "write_timeout", "rocksdb.write.timeout"),
"rocksdb.write.timeout": newDesc(rocksDB, "write_timeout", "rocksdb.write.timeout"), // called `rocksdb_write_timedout` in SHOW GLOBAL STATUS
"rocksdb.write.wal": newDesc(rocksDB, "write_wal", "rocksdb.write.wal"),
}
)
Expand Down
22 changes: 13 additions & 9 deletions collector/engine_rocksdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
_ "github.com/go-sql-driver/mysql" // register driver
"github.com/percona/exporter_shared/helpers"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/smartystreets/goconvey/convey"
)

Expand Down Expand Up @@ -67,7 +66,7 @@ func TestScrapeEngineRocksDBStatus(t *testing.T) {
t.Skip("RocksDB is not enabled, skipping test")
}

convey.Convey("Metrics collection", t, func() {
convey.Convey("Metrics collection", t, convey.FailureContinues, func() {
ch := make(chan prometheus.Metric)
go func() {
err := ScrapeEngineRocksDBStatus(db, ch)
Expand All @@ -77,15 +76,20 @@ func TestScrapeEngineRocksDBStatus(t *testing.T) {
close(ch)
}()

var found int
// check that we found all metrics we expect
expected := make(map[string]struct{})
for k := range engineRocksDBStatusTypes {
expected[k] = struct{}{}
}
for m := range ch {
got := helpers.ReadMetric(m)
if got.Name == "mysql_engine_rocksdb_bytes_read" {
convey.So(got.Type, convey.ShouldEqual, dto.MetricType_COUNTER)
convey.So(got.Value, convey.ShouldBeGreaterThan, 0)
found++
}
convey.So(expected, convey.ShouldContainKey, got.Help)
delete(expected, got.Help)
}
convey.So(found, convey.ShouldEqual, 1)
// two exceptions
convey.So(expected, convey.ShouldResemble, map[string]struct{}{
"rocksdb.l0.hit": struct{}{},
"rocksdb.l1.hit": struct{}{},
})
})
}
22 changes: 12 additions & 10 deletions vendor/github.com/percona/exporter_shared/helpers/helpers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"revisionTime": "2016-04-24T11:30:07Z"
},
{
"checksumSHA1": "hlMPi8/SmdReaBRR0dqEWsYVMvg=",
"checksumSHA1": "BwRvsVaeoszCaubPyvw85c4ixLs=",
"path": "github.com/percona/exporter_shared/helpers",
"revision": "b61ecbac3b73768e613063577adfcabe7628cb9d",
"revisionTime": "2017-08-29T10:33:34Z"
"revision": "770ea06784d962fae60681973886f8cfed9ce7da",
"revisionTime": "2017-09-12T13:48:10Z"
},
{
"checksumSHA1": "KkB+77Ziom7N6RzSbyUwYGrmDeU=",
Expand Down

0 comments on commit 6169494

Please sign in to comment.