forked from influxdata/influxdb-client-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFluxRawExample.cs
More file actions
35 lines (32 loc) · 1.14 KB
/
FluxRawExample.cs
File metadata and controls
35 lines (32 loc) · 1.14 KB
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
using System;
using System.Threading.Tasks;
using InfluxDB.Client.Flux;
namespace Examples
{
public static class FluxRawExample
{
public static async Task Main(string[] args)
{
using var fluxClient = FluxClientFactory.Create("http://localhost:8086/");
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 fluxClient.QueryRawAsync(fluxQuery, line =>
{
// process the flux query result record
Console.WriteLine(line);
},
onError: error =>
{
// error handling while processing result
Console.WriteLine(error.ToString());
},
onComplete: () =>
{
// on complete
Console.WriteLine("Query completed");
});
}
}
}