monogon-dev / NetMeta

NetMeta is a scalable network observability toolkit optimized for performance.
https://netmeta.demo.monogon.dev/
Apache License 2.0
133 stars 8 forks source link

Next Hop graph is cut off #131

Closed yu-re-ka closed 8 months ago

yu-re-ka commented 9 months ago

The query for the Next Hop panel in the overview dashboard has a LIMIT 100, but each output row is a data point and not a time series, so it cuts off the panel after the 100 earliest resulting data points.

yu-re-ka commented 9 months ago

Patch by @n0emis


diff --git a/deploy/dashboards/NetMeta_Overview.cue b/deploy/dashboards/NetMeta_Overview.cue
index 42cff43..bbd0662 100644
--- a/deploy/dashboards/NetMeta_Overview.cue
+++ b/deploy/dashboards/NetMeta_Overview.cue
@@ -65,17 +65,20 @@ _trafficStatisticQueries: {
            """#
    "Top 100 Next Hop":
        #"""
-           SELECT
+           SELECT time, NextHop, BitsPerSecond
+           FROM
+           (SELECT
                $__timeInterval(TimeReceived) as time,
                NextHop,
-               (sum(Bytes * SamplingRate) * 8 / $__interval_s) AS BitsPerSecond
+               (sum(Bytes * SamplingRate) * 8 / $__interval_s) AS BitsPerSecond,
+               row_number() over (partition by time order by BitsPerSecond DESC) as row_num
            FROM flows_raw
            WHERE $__timeFilter(TimeReceived)
            \#(_filtersWithHost)
            AND NextHop != toIPv6('::')
            GROUP BY time, NextHop
-           ORDER BY time
-           LIMIT 100
+           ORDER BY time) as subquery
+           where row_num <= 100
            """#
    "Traffic per Ingress Interface":
        #"""
fionera commented 9 months ago

@n0emis is it fine for you if I make a commit with that patch with you as author?

n0emis commented 9 months ago

Yes, sure. Go ahead