All Projects → influxdata → Influxdb Client Csharp

influxdata / Influxdb Client Csharp

Licence: mit
InfluxDB 2.0 C# Client

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Influxdb Client Csharp

Influxdb Client Python
InfluxDB 2.0 python client
Stars: ✭ 165 (+26.92%)
Mutual labels:  reactive, influxdb, timeseries, flux
influxdb-client-ruby
InfluxDB 2.0 Ruby Client
Stars: ✭ 30 (-76.92%)
Mutual labels:  flux, timeseries, influxdb
nifi-influxdb-bundle
InfluxDB Processors For Apache NiFi
Stars: ✭ 30 (-76.92%)
Mutual labels:  flux, timeseries, influxdb
hastic
Hastic standalone
Stars: ✭ 37 (-71.54%)
Mutual labels:  timeseries, influxdb
InfluxDB.Client.Net
A C# client object model to help integrate with InfluxDB with CLI languages. Supports both .Net traditional and .Net Core.
Stars: ✭ 95 (-26.92%)
Mutual labels:  timeseries, influxdb
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (-21.54%)
Mutual labels:  flux, reactive
influxdbr
R Interface for InfluxDB
Stars: ✭ 95 (-26.92%)
Mutual labels:  timeseries, influxdb
Reactor Core
Non-Blocking Reactive Foundation for the JVM
Stars: ✭ 3,891 (+2893.08%)
Mutual labels:  reactive, flux
Hastic Server
Hastic data management server for analyzing patterns and anomalies from Grafana
Stars: ✭ 292 (+124.62%)
Mutual labels:  influxdb, timeseries
Reatom
State manager with a focus of all needs
Stars: ✭ 567 (+336.15%)
Mutual labels:  reactive, flux
Facette
Time series data visualization software
Stars: ✭ 1,115 (+757.69%)
Mutual labels:  influxdb, timeseries
redrock
Typesafe, reactive redux
Stars: ✭ 14 (-89.23%)
Mutual labels:  flux, reactive
Scalecube Services
v2.0 - ScaleCube Services provides a low latency Reactive Microservices library for serverless service registry and discovery based on gossip protocol and without single point-of-failure or bottlenecks.
Stars: ✭ 23 (-82.31%)
Mutual labels:  reactive, flux
Rx Connect
Glue your state and pure React components with RxJS
Stars: ✭ 86 (-33.85%)
Mutual labels:  reactive, flux
continuous-analytics-examples
A collection of examples of continuous analytics.
Stars: ✭ 17 (-86.92%)
Mutual labels:  flux, influxdb
Vueflux
♻️ Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux
Stars: ✭ 315 (+142.31%)
Mutual labels:  reactive, flux
Reactor Netty
TCP/HTTP/UDP/QUIC client/server with Reactor over Netty
Stars: ✭ 1,743 (+1240.77%)
Mutual labels:  reactive, flux
Reactor Addons
Official modules for the Reactor project
Stars: ✭ 175 (+34.62%)
Mutual labels:  reactive, flux
Node Influx
📈 The InfluxDB Client for Node.js and Browsers
Stars: ✭ 820 (+530.77%)
Mutual labels:  influxdb, timeseries
Influxgraph
Graphite InfluxDB backend. InfluxDB storage finder / plugin for Graphite API.
Stars: ✭ 87 (-33.08%)
Mutual labels:  influxdb, timeseries

influxdb-client-csharp

CircleCI codecov Nuget License GitHub issues GitHub pull requests Slack Status

This repository contains the reference C# client for the InfluxDB 2.0.

Note: Use this client library with InfluxDB 2.x and InfluxDB 1.8+ (see details). For connecting to InfluxDB 1.7 or earlier instances, use the influxdb-csharp client library.

Features

  • Supports querying using the Flux language over the InfluxDB 1.7+ REST API (/api/v2/query endpoint)
  • InfluxDB 2.0 client
    • Querying data using the Flux language
    • Writing data using
    • InfluxDB 2.0 Management API client for managing
      • sources, buckets
      • tasks
      • authorizations
      • health check
      • ...

Documentation

The C# clients are implemented for the InfluxDB 2.0 and InfluxDB 1.7+:

Client Description Documentation Compatibility
Client The reference C# client that allows query, write and InfluxDB 2.0 management. readme 2.0
Client.Legacy The reference C# client that allows you to perform Flux queries against InfluxDB 1.7+. readme 1.7+

How To Use

This clients are a work in progress and hosted in Bonitoo.io Nuget Repository.

If you want to use it with a .Net CLI or Package Manager, you have to specify source of packages. See examples below.

Writes and Queries in InfluxDB 2.0

The following example demonstrates how to write data to InfluxDB 2.0 and read them back using the Flux language:

Installation

Use the latest version:

.Net CLI
dotnet add package InfluxDB.Client
Or when using Package Manager
Install-Package InfluxDB.Client
using System;
using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using InfluxDB.Client.Core;
using InfluxDB.Client.Writes;
using Task = System.Threading.Tasks.Task;

namespace Examples
{
    public static class QueriesWritesExample
    {
        private static readonly char[] Token = "".ToCharArray();

        public static async Task Main(string[] args)
        {
            var influxDBClient = InfluxDBClientFactory.Create("http://localhost:8086", Token);

            //
            // Write Data
            //
            using (var writeApi = influxDBClient.GetWriteApi())
            {
                //
                // Write by Point
                //
                var point = PointData.Measurement("temperature")
                    .Tag("location", "west")
                    .Field("value", 55D)
                    .Timestamp(DateTime.UtcNow.AddSeconds(-10), WritePrecision.Ns);
                
                writeApi.WritePoint("bucket_name", "org_id", point);
                
                //
                // Write by LineProtocol
                //
                writeApi.WriteRecord("bucket_name", "org_id", WritePrecision.Ns, "temperature,location=north value=60.0");
                
                //
                // Write by POCO
                //
                var temperature = new Temperature {Location = "south", Value = 62D, Time = DateTime.UtcNow};
                writeApi.WriteMeasurement("bucket_name", "org_id", WritePrecision.Ns, temperature);
            }
            
            //
            // Query data
            //
            var flux = "from(bucket:\"temperature-sensors\") |> range(start: 0)";

            var fluxTables = await influxDBClient.GetQueryApi().QueryAsync(flux, "org_id");
            fluxTables.ForEach(fluxTable =>
            {
                var fluxRecords = fluxTable.Records;
                fluxRecords.ForEach(fluxRecord =>
                {
                    Console.WriteLine($"{fluxRecord.GetTime()}: {fluxRecord.GetValue()}");
                });
            });

            influxDBClient.Dispose();
        }
        
        [Measurement("temperature")]
        private class Temperature
        {
            [Column("location", IsTag = true)] public string Location { get; set; }

            [Column("value")] public double Value { get; set; }

            [Column(IsTimestamp = true)] public DateTime Time;
        }
    }
}

Use Management API to create a new Bucket in InfluxDB 2.0

The following example demonstrates how to use a InfluxDB 2.0 Management API. For further information see client documentation.

Installation

Use the latest version:

.Net CLI
dotnet add package InfluxDB.Client
Or when using Package Manager
Install-Package InfluxDB.Client
using System.Collections.Generic;
using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using Task = System.Threading.Tasks.Task;

namespace Examples
{
    public static class ManagementExample
    {
        private static readonly char[] Token = "".ToCharArray();

        public static async Task Main(string[] args)
        {
            var influxDBClient = InfluxDBClientFactory.Create("http://localhost:8086", Token);

            //
            // Create bucket "iot_bucket" with data retention set to 3,600 seconds
            //
            var retention = new BucketRetentionRules(BucketRetentionRules.TypeEnum.Expire, 3600);

            var bucket = await influxDBClient.GetBucketsApi().CreateBucketAsync("iot_bucket", retention, "org_id");
            
            //
            // Create access token to "iot_bucket"
            //
            var resource = new PermissionResource{Id = bucket.Id, OrgID = "org_id",Type = PermissionResource.TypeEnum.Buckets};

            // Read permission
            var read = new Permission{Resource = resource, Action = Permission.ActionEnum.Read};
            
            // Write permission
            var write = new Permission{Resource = resource, Action = Permission.ActionEnum.Write};

            var authorization = await influxDBClient.GetAuthorizationsApi()
                .CreateAuthorizationAsync("org_id", new List<Permission> {read, write});

            
            //
            // Created token that can be use for writes to "iot_bucket"
            //
            var token = authorization.Token;
            
            influxDBClient.Dispose();
        }        
    }
}

InfluxDB 1.8 API compatibility

InfluxDB 1.8.0 introduced forward compatibility APIs for InfluxDB 2.0. This allow you to easily move from InfluxDB 1.x to InfluxDB 2.0 Cloud or open source.

The following forward compatible APIs are available:

API Endpoint Description
QueryApi.cs /api/v2/query Query data in InfluxDB 1.8.0+ using the InfluxDB 2.0 API and Flux (endpoint should be enabled by flux-enabled option)
WriteApi.cs /api/v2/write Write data to InfluxDB 1.8.0+ using the InfluxDB 2.0 API
HealthAsync /health Check the health of your InfluxDB instance

For detail info see InfluxDB 1.8 example.

Flux queries in InfluxDB 1.7+

The following example demonstrates querying using the Flux language.

Installation

Use the latest version:

.Net CLI
dotnet add package InfluxDB.Client.Flux
Or when using Package Manager
Install-Package InfluxDB.Client.Flux
using System;
using InfluxDB.Client.Flux;

namespace Examples
{
    public static class FluxExample
    {
        public static void Run()
        {
            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)";

            fluxClient.QueryAsync(fluxQuery, (cancellable, 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");
                            }).GetAwaiter().GetResult();
        }
    }
}

Contributing

If you would like to contribute code you can do through GitHub by forking the repository and sending a pull request into the master branch.

License

The InfluxDB 2.0 Clients are released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].