Giter VIP home page Giter VIP logo

influxdb.bulkinsert's Introduction

Influxdb.BulkInsert

Latest version

Influxdb 异步、快速、批量插入组件,支持http和udp协议,目前不支持https。

开始

1.HTTP

var insert = new InfluxHttpBulkInsert(new InfluxConnectionSetting() { Server = "192.168.10.110", Port = 8086,Database = "kong",BitchSize = 5000});
var processor = new InfluxBulkInsertProcessor(insert);

processor.Open();
for (int i = 0; i < 1000; i++)
{
    processor.Write($"test,type='cpu' value=1 {InfluxdbTimeGen.GenNanosecond()}");
}

Console.WriteLine("Complete");
Console.Read();
processor.Close();

2.UDP

var insert = new InfluxUdpBulkInsert(new InfluxConnectionSetting() { Server = "192.168.10.110", Port = 8089,BitchSize = 10});
var processor = new InfluxBulkInsertProcessor(insert);

processor.Open();
for (int i = 0; i < 1000; i++)
{
    processor.Write($"test,type='cpu' value={i} {InfluxdbTimeGen.GenNanosecond()}");
}
Console.WriteLine("Complete");
Console.Read();
processor.Close();

使用规范

1.写入的数据末尾字符不得带换行 ”\n“

这种不被允许:

test,type='cpu' value=1\n
test,type='cpu' value=1\ntest,type='cpu' value=1\n

这种允许:

test,type='cpu' value=1
test,type='cpu' value=1\ntest,type='cpu' value=1

2.写入数据必须带上时间戳

因为发送数据是按批次发送,如果批次的数据数量大于1(BitchSize),那么数据是合并发送的,这时需要每条数据都带上时间戳,不然数据将会被覆盖。可以使用 InfluxdbTimeGen.GenNanosecond()来生成纳秒时间戳,时间戳必须为纳秒。

3.数据格式

<measurement>,<tags> <fields> <time>

示例:

test,type='cpu' value=1 1539076079817999232
test,type='cpu' value=1 1539076079817999232\ntest,type='cpu' value=1 1539076079817999232

influxdb.bulkinsert's People

Contributors

stulzq avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.