influxdb 查询测量中所有系列的最后一行

influxdb query last row of all series in a measurement

我试图找到一种方法来获取测量中每个系列的最新行。

例如:

假设 results 测量中的系列是:

> select series from test_result
results,service=MyService,team=A
result,service=MyService,team=B
test_result,service=MyService,team=C

给定时间范围内的行是:

> select * from test_result order by time desc

time                service     team       status duration
----                -------     ----       ------ --------
1523370939000000000 MyService A 1      300
1523370940000000000 MyService B 1      300
1523370941000000000 MyService A 1      300
1523370941000000000 MyService C 1      300
1523371748000000000 MyService A 1      300
1523371749000000000 MyService B 1      300
1523371750000000000 MyService B 1      300
1523371754000000000 MyService A 1      300

我希望查询 return 第一行、第二行和第四行。 非常感谢任何帮助。

谢谢!

感谢来自 Influx Staff 的 Katy 回答了问题:

To separate the series, you can add GROUP BY , which will give you the results separated by series. Then you can add aggregates to your query, like LAST. For example: SELECT LAST(field_name), from test_result GROUP BY *

Keep in mind that your fields are also a factor here. You can use * without specifying a field, but there’s room for error there. It’s better to specify a field if you know what you need.