Compare commits

...

2 Commits

Author SHA1 Message Date
Ulric Qin
efaafe6e05 report sample channel size 2022-07-07 09:59:18 +08:00
Ulric Qin
725c0d666d report sample queue size 2022-07-07 09:55:31 +08:00
2 changed files with 22 additions and 0 deletions

View File

@@ -49,6 +49,14 @@ var (
Name: "alert_queue_size",
Help: "The size of alert queue.",
}, []string{"cluster"})
// 数据转发队列,各个队列的长度
GaugeSampleQueueSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "sample_queue_size",
Help: "The size of sample queue.",
}, []string{"cluster", "channel_number"})
)
func Init() {

View File

@@ -16,6 +16,8 @@ import (
"github.com/prometheus/client_golang/api"
"github.com/prometheus/prometheus/prompb"
"github.com/toolkits/pkg/logger"
promstat "github.com/didi/nightingale/v5/src/server/stat"
)
type WriterType struct {
@@ -192,6 +194,8 @@ func Init(opts []config.WriterOptions, globalOpt config.WriterGlobalOpt) error {
go Writers.StartConsumer(i, Writers.chans[i])
}
go reportChanSize()
for i := 0; i < len(opts); i++ {
cli, err := api.NewClient(api.Config{
Address: opts[i].Url,
@@ -226,3 +230,13 @@ func Init(opts []config.WriterOptions, globalOpt config.WriterGlobalOpt) error {
return nil
}
func reportChanSize() {
for {
time.Sleep(time.Second * 3)
for i, c := range Writers.chans {
size := len(c)
promstat.GaugeSampleQueueSize.WithLabelValues(config.C.ClusterName, fmt.Sprint(i)).Set(float64(size))
}
}
}