Skip to content

Commit

Permalink
Merge pull request #103 from percona/v0.6.x
Browse files Browse the repository at this point in the history
PMM-2591: v0.6.0
  • Loading branch information
arvenil authored Jun 13, 2018
2 parents 8136fdd + c7c0029 commit a642618
Show file tree
Hide file tree
Showing 70 changed files with 3,795 additions and 145 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
mongodb_exporter
coverage.txt
coverage_temp.txt
/.history
/.idea
4 changes: 2 additions & 2 deletions Gopkg.lock

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

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
GO := go
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
PROMU := $(FIRST_GOPATH)/bin/promu -v
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
pkgs = ./...

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Based on [MongoDB exporter](https://github.com/dcu/mongodb_exporter) by David Cu
- MongoDB Sharding metrics (*shards, chunks, db/collections, balancer operations*)
- MongoDB RocksDB storage-engine metrics (*levels, compactions, cache usage, i/o rates, etc*)
- MongoDB WiredTiger storage-engine metrics (*cache, blockmanger, tickets, etc*)
- MongoDB Top Metrics per collection (writeLock, readLock, query, etc*)


## Building and running
Expand Down
Binary file added collector/fixtures/top_status.bson
Binary file not shown.
272 changes: 272 additions & 0 deletions collector/fixtures/top_status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
{
"totals" : {
"note" : "all times in microseconds",
"admin.system.roles" : {
"total" : {
"time" : 15,
"count" : 1
},
"readLock" : {
"time" : 15,
"count" : 1
},
"writeLock" : {
"time" : 0,
"count" : 0
},
"queries" : {
"time" : 15,
"count" : 1
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 0,
"count" : 0
}
},
"admin.system.version" : {
"total" : {
"time" : 4,
"count" : 1
},
"readLock" : {
"time" : 4,
"count" : 1
},
"writeLock" : {
"time" : 0,
"count" : 0
},
"queries" : {
"time" : 0,
"count" : 0
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 0,
"count" : 0
}
},
"dummy.collection" : {
"total" : {
"time" : 61,
"count" : 2
},
"readLock" : {
"time" : 61,
"count" : 2
},
"writeLock" : {
"time" : 0,
"count" : 0
},
"queries" : {
"time" : 61,
"count" : 2
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 0,
"count" : 0
}
},
"dummy.users" : {
"total" : {
"time" : 1095531,
"count" : 17428
},
"readLock" : {
"time" : 267953,
"count" : 17420
},
"writeLock" : {
"time" : 827578,
"count" : 8
},
"queries" : {
"time" : 899,
"count" : 10
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 826929,
"count" : 5
},
"update" : {
"time" : 456,
"count" : 2
},
"remove" : {
"time" : 193,
"count" : 1
},
"commands" : {
"time" : 0,
"count" : 0
}
},
"local.oplog.rs" : {
"total" : {
"time" : 337,
"count" : 20
},
"readLock" : {
"time" : 337,
"count" : 20
},
"writeLock" : {
"time" : 0,
"count" : 0
},
"queries" : {
"time" : 0,
"count" : 0
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 337,
"count" : 20
}
},
"local.startup_log" : {
"total" : {
"time" : 55073,
"count" : 17439
},
"readLock" : {
"time" : 55071,
"count" : 17438
},
"writeLock" : {
"time" : 2,
"count" : 1
},
"queries" : {
"time" : 0,
"count" : 0
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 0,
"count" : 0
}
},
"local.system.replset" : {
"total" : {
"time" : 21,
"count" : 2
},
"readLock" : {
"time" : 21,
"count" : 2
},
"writeLock" : {
"time" : 0,
"count" : 0
},
"queries" : {
"time" : 0,
"count" : 0
},
"getmore" : {
"time" : 0,
"count" : 0
},
"insert" : {
"time" : 0,
"count" : 0
},
"update" : {
"time" : 0,
"count" : 0
},
"remove" : {
"time" : 0,
"count" : 0
},
"commands" : {
"time" : 0,
"count" : 0
}
}
},
"ok" : 1
}
2 changes: 1 addition & 1 deletion collector/mongod/asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package collector_mongod
package mongod

import (
"github.com/prometheus/client_golang/prometheus"
Expand Down
2 changes: 1 addition & 1 deletion collector/mongod/background_flushing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package collector_mongod
package mongod

import (
"time"
Expand Down
31 changes: 23 additions & 8 deletions collector/mongod/collections_status.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package collector_mongod
package mongod

import (
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -44,6 +44,12 @@ var (
Name: "indexes_size",
Help: "The total size of all indexes",
}, []string{"db", "coll"})
collectionIndexSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: "db_coll",
Name: "index_size",
Help: "The individual index size",
}, []string{"db", "coll", "index"})
)

// CollectionStatList contains stats from all collections
Expand All @@ -55,12 +61,12 @@ type CollectionStatList struct {
type CollectionStatus struct {
Database string
Name string
Size int `bson:"size,omitempty"`
Count int `bson:"count,omitempty"`
AvgObjSize int `bson:"avgObjSize,omitempty"`
StorageSize int `bson:"storageSize,omitempty"`
Indexes int `bson:"indexSizes,omitempty"`
IndexesSize int `bson:"totalIndexSize,omitempty"`
Size int `bson:"size,omitempty"`
Count int `bson:"count,omitempty"`
AvgObjSize int `bson:"avgObjSize,omitempty"`
StorageSize int `bson:"storageSize,omitempty"`
IndexesSize int `bson:"totalIndexSize,omitempty"`
IndexSizes map[string]float64 `bson:"indexSizes,omitempty"`
}

// Export exports database stats to prometheus
Expand All @@ -74,15 +80,24 @@ func (collStatList *CollectionStatList) Export(ch chan<- prometheus.Metric) {
collectionObjectCount.With(ls).Set(float64(member.Count))
collectionAvgObjSize.With(ls).Set(float64(member.AvgObjSize))
collectionStorageSize.With(ls).Set(float64(member.StorageSize))
collectionIndexes.With(ls).Set(float64(member.Indexes))
collectionIndexes.With(ls).Set(float64(len(member.IndexSizes)))
collectionIndexesSize.With(ls).Set(float64(member.IndexesSize))
for indexName, size := range member.IndexSizes {
ls = prometheus.Labels{
"db": member.Database,
"coll": member.Name,
"index": indexName,
}
collectionIndexSize.With(ls).Set(size)
}
}
collectionSize.Collect(ch)
collectionObjectCount.Collect(ch)
collectionAvgObjSize.Collect(ch)
collectionStorageSize.Collect(ch)
collectionIndexes.Collect(ch)
collectionIndexesSize.Collect(ch)
collectionIndexSize.Collect(ch)
}

// Describe describes database stats for prometheus
Expand Down
2 changes: 1 addition & 1 deletion collector/mongod/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package collector_mongod
package mongod

import (
"github.com/prometheus/client_golang/prometheus"
Expand Down
Loading

0 comments on commit a642618

Please sign in to comment.