Implement filter in status, website and uri in CLI and Frontend
This commit is contained in:
@@ -92,6 +92,7 @@ func (c *Cache) mergeFineBuckets(now time.Time) st.Snapshot {
|
||||
|
||||
// QueryTopN answers a TopN request from the ring buffers.
|
||||
func (c *Cache) QueryTopN(filter *pb.Filter, groupBy pb.GroupBy, n int, window pb.Window) []st.Entry {
|
||||
cf := st.CompileFilter(filter)
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
@@ -101,7 +102,7 @@ func (c *Cache) QueryTopN(filter *pb.Filter, groupBy pb.GroupBy, n int, window p
|
||||
idx := (buckets.Head - 1 - i + buckets.Size) % buckets.Size
|
||||
for _, e := range buckets.Ring[idx].Entries {
|
||||
t := st.LabelTuple(e.Label)
|
||||
if !st.MatchesFilter(t, filter) {
|
||||
if !st.MatchesFilter(t, cf) {
|
||||
continue
|
||||
}
|
||||
grouped[st.DimensionLabel(t, groupBy)] += e.Count
|
||||
@@ -112,6 +113,7 @@ func (c *Cache) QueryTopN(filter *pb.Filter, groupBy pb.GroupBy, n int, window p
|
||||
|
||||
// QueryTrend answers a Trend request from the ring buffers.
|
||||
func (c *Cache) QueryTrend(filter *pb.Filter, window pb.Window) []st.TrendPoint {
|
||||
cf := st.CompileFilter(filter)
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
@@ -122,7 +124,7 @@ func (c *Cache) QueryTrend(filter *pb.Filter, window pb.Window) []st.TrendPoint
|
||||
snap := buckets.Ring[idx]
|
||||
var total int64
|
||||
for _, e := range snap.Entries {
|
||||
if st.MatchesFilter(st.LabelTuple(e.Label), filter) {
|
||||
if st.MatchesFilter(st.LabelTuple(e.Label), cf) {
|
||||
total += e.Count
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user