1

I trying to find a way to get the most recent row for each serie in a measurement.

for example:

Assuming the series in results measurement are:

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

and the rows in a given time frame are:

> 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

I would expect the query to return the first, second and fourth rows. Any help is much appreciated.

Thanks!

Roy A
  • 21
  • 1
  • 4
  • I think this addresses your question: https://stackoverflow.com/questions/29193898/influxdb-getting-only-last-value-in-query – Dan S Apr 26 '18 at 13:12
  • thanks danS this will returns the last row for the entire measurement. I would like to get the last row for all combinations of the tags (series). so if the measurement has 50 combinations of tags, it would return 50 rows back. – Roy A Apr 26 '18 at 13:19
  • Adding a `GROUP BY service, team` should do what you need. – Jason Apr 29 '18 at 10:20

1 Answers1

1

Thanks to Katy from Influx Staff who answered the question:

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.

Roy A
  • 21
  • 1
  • 4