Skip to content

Support dynamic queries #1090

@nathanielc

Description

@nathanielc

The use case is to be able to use the result of a query in part of another query.

The classic example of this is the top N use case:

// Gather the top 10 hosts by mem used_percent over the last day.
hosts = from(bucket:"telegraf/autogen")
    |> range(start: -1d)
    |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent")
    |> max()
    |> group()
    |> top(n: 10)
    |> columnSlice(column: "host")

// Select the last 30d of cpu usage for only the top 10 hosts
from(bucket:"telegraf/autogen") 
     |> range(start: -30d)
     |> filter(fn: (r) => r._measurement == "cpu" and r.host in hosts)

This depends on #1085

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions