-
Notifications
You must be signed in to change notification settings - Fork 93
/
FluxClientExample.cs
36 lines (32 loc) · 1.17 KB
/
FluxClientExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Threading.Tasks;
using InfluxDB.Client.Flux;
namespace Examples
{
public static class FluxClientExample
{
public static async Task Main()
{
var options = new FluxConnectionOptions("http://127.0.0.1:8086");
using var client = new FluxClient(options);
var fluxQuery = "from(bucket: \"telegraf\")\n"
+ " |> filter(fn: (r) => (r[\"_measurement\"] == \"cpu\" AND r[\"_field\"] == \"usage_system\"))"
+ " |> range(start: -1d)"
+ " |> sample(n: 5, pos: 1)";
await client.QueryAsync(fluxQuery, record =>
{
// process the flux query records
Console.WriteLine(record.GetTime() + ": " + record.GetValue());
},
(error) =>
{
// error handling while processing result
Console.WriteLine(error.ToString());
}, () =>
{
// on complete
Console.WriteLine("Query completed");
});
}
}
}