我是InfluxDB的新手。我用它来存储ntopng时间序列数据。
ntopng编写了一个名为asn:traffic
的测量,用于存储ASN发送和接收的字节数。
> show tag keys from "asn:traffic"
name: asn:traffic
tagKey
------
asn
ifid
> show field keys from "asn:traffic"
name: asn:traffic
fieldKey fieldType
-------- ---------
bytes_rcvd float
bytes_sent float
>
我可以运行查询以查看特定ASN的bps数据速率:
> SELECT non_negative_derivative(mean("bytes_rcvd"), 1s) * 8 FROM "asn:traffic" WHERE "asn" = '2906' AND time >= now() - 12h GROUP BY time(30s) fill(none)
name: asn:traffic
time non_negative_derivative
---- -----------------------
1550294640000000000 30383200
1550294700000000000 35639600
...
...
...
>
但是,我想要做的是创建一个查询,我可以使用该查询按数据速率返回前N个ASN并在Grafana图上绘制。有点像使用ELK的this示例。
我已经在这里和其他地方的帖子中尝试过一些变种,但是我无法得到我想要的东西。例如,我认为这个查询让我更接近我想要的位置,但asn
中没有值:
> select top(bps,asn,10) from (SELECT non_negative_derivative(mean(bytes_rcvd), 1s) * 8 as bps FROM "asn:traffic" WHERE time >= now() - 12h GROUP BY time(30s) fill(none))
name: asn:traffic
time top asn
---- --- ---
1550299860000000000 853572800
1550301660000000000 1197327200
1550301720000000000 1666883866.6666667
1550310780000000000 674889600
1550329320000000000 20979431866.666668
1550332740000000000 707015600
1550335920000000000 2066646533.3333333
1550336820000000000 618554933.3333334
1550339280000000000 669084933.3333334
1550340300000000000 704147333.3333334
>
然后想一想也许子查询也需要选择asn
,但是这会产生关于混合查询的错误:
> select top(bps,asn,10) from (SELECT asn, non_negative_derivative(mean(bytes_rcvd), 1s) * 8 as bps FROM "asn:traffic" WHERE time >= now() - 12h GROUP BY time(30s) fill(none))
ERR: mixing aggregate and non-aggregate queries is not supported
>
有人对解决方案有任何想法吗?
编辑1
根据George Shuklin的建议,修改查询以在asn
中包含GROUP BY
会在CLI输出中显示ASN,但是doesn't translate in Grafana。我期待一个堆叠图,堆叠图的每一层都是前10个asn结果之一。
尝试将ASN作为标记,而不是使用group by time(30s), 'asn'
,并且该标记将在外部查询中可用。