fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Add metric for total number of shards (#891)

Currently, we only record the number of compound shards. This PR adds a metric
for the total number of index shards. This metric is helpful for alerting, as
it's important to catch a significant decrease in the number of indexed data.

+18 -5
+5
cmd/zoekt-sourcegraph-indexserver/cleanup.go
··· 379 379 Help: "Set to 1 if indexserver's vacuum job is running.", 380 380 }) 381 381 382 + var metricNumberShards = promauto.NewGauge(prometheus.GaugeOpts{ 383 + Name: "index_number_shards", 384 + Help: "The number of total shards.", 385 + }) 386 + 382 387 var metricNumberCompoundShards = promauto.NewGauge(prometheus.GaugeOpts{ 383 388 Name: "index_number_compound_shards", 384 389 Help: "The number of compound shards.",
+13 -5
cmd/zoekt-sourcegraph-indexserver/main.go
··· 376 376 missing := s.queue.Bump(repos.IDs) 377 377 s.Sourcegraph.ForceIterateIndexOptions(s.queue.AddOrUpdate, func(uint32, error) {}, missing...) 378 378 379 - setCompoundShardCounter(s.IndexDir) 379 + setShardsCounter(s.IndexDir) 380 380 381 381 <-cleanupDone 382 382 } ··· 1208 1208 return strings.Join(xs, sep) 1209 1209 } 1210 1210 1211 - func setCompoundShardCounter(indexDir string) { 1212 - fns, err := filepath.Glob(filepath.Join(indexDir, "compound-*.zoekt")) 1211 + func setShardsCounter(indexDir string) { 1212 + fns, err := filepath.Glob(filepath.Join(indexDir, "*.zoekt")) 1213 1213 if err != nil { 1214 - errorLog.Printf("setCompoundShardCounter: %s\n", err) 1214 + errorLog.Printf("setShardsCounter: %s\n", err) 1215 1215 return 1216 + } 1217 + metricNumberShards.Set(float64(len(fns))) 1218 + 1219 + compoundFns := make([]string, 0, len(fns)) 1220 + for _, fn := range fns { 1221 + if strings.HasPrefix(filepath.Base(fn), "compound-") { 1222 + compoundFns = append(compoundFns, fn) 1223 + } 1216 1224 } 1217 1225 metricNumberCompoundShards.Set(float64(len(fns))) 1218 1226 } ··· 1288 1296 } 1289 1297 1290 1298 profiler.Init("zoekt-sourcegraph-indexserver") 1291 - setCompoundShardCounter(s.IndexDir) 1299 + setShardsCounter(s.IndexDir) 1292 1300 1293 1301 if conf.listen != "" { 1294 1302