Skip to content

Flux query builder fluent API #187

@empz

Description

@empz

Currently, the queries have to be built manually in a string. It would be great to have a fluent API to build a query.

I know you guys are working on another library to query by using LINQ, but that requires having the data modeled and annotated in C# classes, which is not always possible due to the nature of dynamic data and metrics.

I'm proposing an API that can do things like the following:

var query = influxDb.GetQueryBuilder()
    .From("bucket")
    .Filter(r => r["_measurement"] == "cpu")
    .Filter(r => r["_field"] == "temperature")
    .Filter(r => r["some-tag"] == "some-value")
    .AggregateWindow(every: TimeSpan.FromSeconds(10), fn: InfluxDb.Functions.Mean, createEmpty: false)
    .Yield("mean")
    .ToString();

This way we could be writing queries in a .NET idiomatic way and ensuring the resulting strings are valid Flux queries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions