Skip to content

Commit a642618

Browse files
authored
Merge pull request #103 from percona/v0.6.x
PMM-2591: v0.6.0
2 parents 8136fdd + c7c0029 commit a642618

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3795
-145
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
mongodb_exporter
66
coverage.txt
77
coverage_temp.txt
8+
/.history
9+
/.idea

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
GO := go
1616
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
1717
PROMU := $(FIRST_GOPATH)/bin/promu -v
18-
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
18+
pkgs = ./...
1919

2020
PREFIX ?= $(shell pwd)
2121
BIN_DIR ?= $(shell pwd)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Based on [MongoDB exporter](https://github.com/dcu/mongodb_exporter) by David Cu
1515
- MongoDB Sharding metrics (*shards, chunks, db/collections, balancer operations*)
1616
- MongoDB RocksDB storage-engine metrics (*levels, compactions, cache usage, i/o rates, etc*)
1717
- MongoDB WiredTiger storage-engine metrics (*cache, blockmanger, tickets, etc*)
18+
- MongoDB Top Metrics per collection (writeLock, readLock, query, etc*)
1819

1920

2021
## Building and running

collector/fixtures/top_status.bson

2.37 KB
Binary file not shown.

collector/fixtures/top_status.json

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
{
2+
"totals" : {
3+
"note" : "all times in microseconds",
4+
"admin.system.roles" : {
5+
"total" : {
6+
"time" : 15,
7+
"count" : 1
8+
},
9+
"readLock" : {
10+
"time" : 15,
11+
"count" : 1
12+
},
13+
"writeLock" : {
14+
"time" : 0,
15+
"count" : 0
16+
},
17+
"queries" : {
18+
"time" : 15,
19+
"count" : 1
20+
},
21+
"getmore" : {
22+
"time" : 0,
23+
"count" : 0
24+
},
25+
"insert" : {
26+
"time" : 0,
27+
"count" : 0
28+
},
29+
"update" : {
30+
"time" : 0,
31+
"count" : 0
32+
},
33+
"remove" : {
34+
"time" : 0,
35+
"count" : 0
36+
},
37+
"commands" : {
38+
"time" : 0,
39+
"count" : 0
40+
}
41+
},
42+
"admin.system.version" : {
43+
"total" : {
44+
"time" : 4,
45+
"count" : 1
46+
},
47+
"readLock" : {
48+
"time" : 4,
49+
"count" : 1
50+
},
51+
"writeLock" : {
52+
"time" : 0,
53+
"count" : 0
54+
},
55+
"queries" : {
56+
"time" : 0,
57+
"count" : 0
58+
},
59+
"getmore" : {
60+
"time" : 0,
61+
"count" : 0
62+
},
63+
"insert" : {
64+
"time" : 0,
65+
"count" : 0
66+
},
67+
"update" : {
68+
"time" : 0,
69+
"count" : 0
70+
},
71+
"remove" : {
72+
"time" : 0,
73+
"count" : 0
74+
},
75+
"commands" : {
76+
"time" : 0,
77+
"count" : 0
78+
}
79+
},
80+
"dummy.collection" : {
81+
"total" : {
82+
"time" : 61,
83+
"count" : 2
84+
},
85+
"readLock" : {
86+
"time" : 61,
87+
"count" : 2
88+
},
89+
"writeLock" : {
90+
"time" : 0,
91+
"count" : 0
92+
},
93+
"queries" : {
94+
"time" : 61,
95+
"count" : 2
96+
},
97+
"getmore" : {
98+
"time" : 0,
99+
"count" : 0
100+
},
101+
"insert" : {
102+
"time" : 0,
103+
"count" : 0
104+
},
105+
"update" : {
106+
"time" : 0,
107+
"count" : 0
108+
},
109+
"remove" : {
110+
"time" : 0,
111+
"count" : 0
112+
},
113+
"commands" : {
114+
"time" : 0,
115+
"count" : 0
116+
}
117+
},
118+
"dummy.users" : {
119+
"total" : {
120+
"time" : 1095531,
121+
"count" : 17428
122+
},
123+
"readLock" : {
124+
"time" : 267953,
125+
"count" : 17420
126+
},
127+
"writeLock" : {
128+
"time" : 827578,
129+
"count" : 8
130+
},
131+
"queries" : {
132+
"time" : 899,
133+
"count" : 10
134+
},
135+
"getmore" : {
136+
"time" : 0,
137+
"count" : 0
138+
},
139+
"insert" : {
140+
"time" : 826929,
141+
"count" : 5
142+
},
143+
"update" : {
144+
"time" : 456,
145+
"count" : 2
146+
},
147+
"remove" : {
148+
"time" : 193,
149+
"count" : 1
150+
},
151+
"commands" : {
152+
"time" : 0,
153+
"count" : 0
154+
}
155+
},
156+
"local.oplog.rs" : {
157+
"total" : {
158+
"time" : 337,
159+
"count" : 20
160+
},
161+
"readLock" : {
162+
"time" : 337,
163+
"count" : 20
164+
},
165+
"writeLock" : {
166+
"time" : 0,
167+
"count" : 0
168+
},
169+
"queries" : {
170+
"time" : 0,
171+
"count" : 0
172+
},
173+
"getmore" : {
174+
"time" : 0,
175+
"count" : 0
176+
},
177+
"insert" : {
178+
"time" : 0,
179+
"count" : 0
180+
},
181+
"update" : {
182+
"time" : 0,
183+
"count" : 0
184+
},
185+
"remove" : {
186+
"time" : 0,
187+
"count" : 0
188+
},
189+
"commands" : {
190+
"time" : 337,
191+
"count" : 20
192+
}
193+
},
194+
"local.startup_log" : {
195+
"total" : {
196+
"time" : 55073,
197+
"count" : 17439
198+
},
199+
"readLock" : {
200+
"time" : 55071,
201+
"count" : 17438
202+
},
203+
"writeLock" : {
204+
"time" : 2,
205+
"count" : 1
206+
},
207+
"queries" : {
208+
"time" : 0,
209+
"count" : 0
210+
},
211+
"getmore" : {
212+
"time" : 0,
213+
"count" : 0
214+
},
215+
"insert" : {
216+
"time" : 0,
217+
"count" : 0
218+
},
219+
"update" : {
220+
"time" : 0,
221+
"count" : 0
222+
},
223+
"remove" : {
224+
"time" : 0,
225+
"count" : 0
226+
},
227+
"commands" : {
228+
"time" : 0,
229+
"count" : 0
230+
}
231+
},
232+
"local.system.replset" : {
233+
"total" : {
234+
"time" : 21,
235+
"count" : 2
236+
},
237+
"readLock" : {
238+
"time" : 21,
239+
"count" : 2
240+
},
241+
"writeLock" : {
242+
"time" : 0,
243+
"count" : 0
244+
},
245+
"queries" : {
246+
"time" : 0,
247+
"count" : 0
248+
},
249+
"getmore" : {
250+
"time" : 0,
251+
"count" : 0
252+
},
253+
"insert" : {
254+
"time" : 0,
255+
"count" : 0
256+
},
257+
"update" : {
258+
"time" : 0,
259+
"count" : 0
260+
},
261+
"remove" : {
262+
"time" : 0,
263+
"count" : 0
264+
},
265+
"commands" : {
266+
"time" : 0,
267+
"count" : 0
268+
}
269+
}
270+
},
271+
"ok" : 1
272+
}

collector/mongod/asserts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package collector_mongod
15+
package mongod
1616

1717
import (
1818
"github.com/prometheus/client_golang/prometheus"

collector/mongod/background_flushing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package collector_mongod
15+
package mongod
1616

1717
import (
1818
"time"

collector/mongod/collections_status.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package collector_mongod
1+
package mongod
22

33
import (
44
"github.com/prometheus/client_golang/prometheus"
@@ -44,6 +44,12 @@ var (
4444
Name: "indexes_size",
4545
Help: "The total size of all indexes",
4646
}, []string{"db", "coll"})
47+
collectionIndexSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
48+
Namespace: Namespace,
49+
Subsystem: "db_coll",
50+
Name: "index_size",
51+
Help: "The individual index size",
52+
}, []string{"db", "coll", "index"})
4753
)
4854

4955
// CollectionStatList contains stats from all collections
@@ -55,12 +61,12 @@ type CollectionStatList struct {
5561
type CollectionStatus struct {
5662
Database string
5763
Name string
58-
Size int `bson:"size,omitempty"`
59-
Count int `bson:"count,omitempty"`
60-
AvgObjSize int `bson:"avgObjSize,omitempty"`
61-
StorageSize int `bson:"storageSize,omitempty"`
62-
Indexes int `bson:"indexSizes,omitempty"`
63-
IndexesSize int `bson:"totalIndexSize,omitempty"`
64+
Size int `bson:"size,omitempty"`
65+
Count int `bson:"count,omitempty"`
66+
AvgObjSize int `bson:"avgObjSize,omitempty"`
67+
StorageSize int `bson:"storageSize,omitempty"`
68+
IndexesSize int `bson:"totalIndexSize,omitempty"`
69+
IndexSizes map[string]float64 `bson:"indexSizes,omitempty"`
6470
}
6571

6672
// Export exports database stats to prometheus
@@ -74,15 +80,24 @@ func (collStatList *CollectionStatList) Export(ch chan<- prometheus.Metric) {
7480
collectionObjectCount.With(ls).Set(float64(member.Count))
7581
collectionAvgObjSize.With(ls).Set(float64(member.AvgObjSize))
7682
collectionStorageSize.With(ls).Set(float64(member.StorageSize))
77-
collectionIndexes.With(ls).Set(float64(member.Indexes))
83+
collectionIndexes.With(ls).Set(float64(len(member.IndexSizes)))
7884
collectionIndexesSize.With(ls).Set(float64(member.IndexesSize))
85+
for indexName, size := range member.IndexSizes {
86+
ls = prometheus.Labels{
87+
"db": member.Database,
88+
"coll": member.Name,
89+
"index": indexName,
90+
}
91+
collectionIndexSize.With(ls).Set(size)
92+
}
7993
}
8094
collectionSize.Collect(ch)
8195
collectionObjectCount.Collect(ch)
8296
collectionAvgObjSize.Collect(ch)
8397
collectionStorageSize.Collect(ch)
8498
collectionIndexes.Collect(ch)
8599
collectionIndexesSize.Collect(ch)
100+
collectionIndexSize.Collect(ch)
86101
}
87102

88103
// Describe describes database stats for prometheus

collector/mongod/connections.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package collector_mongod
15+
package mongod
1616

1717
import (
1818
"github.com/prometheus/client_golang/prometheus"

0 commit comments

Comments
 (0)