Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 4 additions & 29 deletions asyncsearcher/async_searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"go.uber.org/zap"

"github.com/ozontech/seq-db/bytespool"
Expand Down Expand Up @@ -49,33 +47,6 @@ const (
infoVersion2 // MIDs stored in nanoseconds
)

var (
asyncSearchActiveSearches = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "in_progress",
Help: "Number of active async searches in progress",
})
asyncSearchDiskUsage = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "disk_usage_bytes",
Help: "Disk space used by async search files in bytes by file type",
}, []string{"file_type"})
asyncSearchStoredRequests = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "stored_requests",
Help: "Number of stored async search requests",
})
asyncSearchReadOnly = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "read_only",
Help: "Indicates if store is in async search read-only mode (can not start a new async search) due to disk usage limits",
})
)

type MappingProvider interface {
GetMapping() seq.Mapping
}
Expand Down Expand Up @@ -134,6 +105,10 @@ func MustStartAsync(config AsyncSearcherConfig, mp MappingProvider, fracs fracma
go as.processRequest(id, fracs)
}

// set limit metrics that allow us to calculate alerts' thresholds
asyncSearchDiskUsageLimit.Set(float64(config.MaxSize))
asyncSearchConcurrencyLimit.Set(float64(config.Workers))

go as.startMaintenance()

return as
Expand Down
45 changes: 45 additions & 0 deletions asyncsearcher/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package asyncsearcher

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

var (
asyncSearchActiveSearches = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "in_progress",
Help: "Number of active async searches in progress",
})
asyncSearchConcurrencyLimit = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "concurrency_limit",
Help: "Maximum number of simultaneously running async searches",
})
asyncSearchDiskUsage = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "disk_usage_bytes",
Help: "Disk space used by async search files in bytes by file type",
}, []string{"file_type"})
asyncSearchDiskUsageLimit = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "disk_usage_limit_bytes",
Help: "Maximum disk space async searches is allowed to use in bytes",
})
asyncSearchStoredRequests = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "stored_requests",
Help: "Number of stored async search requests",
})
asyncSearchReadOnly = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "seq_db_store",
Subsystem: "async_search",
Name: "read_only",
Help: "Indicates if store is in async search read-only mode (can not start a new async search) due to disk usage limits",
})
)
Loading