Giter Site home page Giter Site logo

influxdb's Introduction

influxdb-cpp

A header-only C++ query & write client for InfluxDB.

license Build Status Build status

  • Support versions:
    • InfluxDB v0.9 ~ 1.7
    • Check yourself while using other versions.

Why use influxdb-cpp?

  • Exactly-small:
    • Less than 300 lines and only 10KB+.
  • Easy-to-use:
    • It's designed to be used without extra studies.
  • Easy-to-assemble:
    • Only a tiny header file needs to be included.
  • No-dependencies:
    • Unless STL and std C libraries.

Examples

Before using

  • The very simple thing you should do before using is only:

    #include "influxdb.hpp"

Writing example

  • You should refer to the write syntax while writing series(metrics).

    measurement[,tag-key=tag-value...] field-key=field-value[,field2-key=field2-value...] [unix-nano-timestamp]
    
  • You can rapidly start writing serires by according to the following example.

    influxdb_cpp::server_info si("127.0.0.1", 8086, "db", "usr", "pwd");
    influxdb_cpp::builder()
        .meas("foo")
        .tag("k", "v")
        .tag("x", "y")
        .field("x", 10)
        .field("y", 10.3, 2)
        .field("z", 10.3456)
        .field("b", !!10)
        .timestamp(1512722735522840439)
        .post_http(si);
    • Remarks:
      • 3rd parameter precision of field() is optional for floating point value, and default precision is 2.
      • usr and pwd is optional for authorization.
  • The series sent is:

    foo,k=v,x=y x=10i,y=10.30,z=10.35,b=t 1512722735522840439
    
  • You could change post_http to send_udp for udp request. And only host and port is required for udp.

    influxdb_cpp::builder()
        .meas("foo")
        .field("x", 10)
        .send_udp("127.0.0.1", 8091);
  • Bulk/batch/multiple insert also supports:

    influxdb_cpp::builder()
        .meas("foo")  // series 1
        .field("x", 10)
    
        .meas("bar")  // series 2
        .field("y", 10.3)
        .send_udp("127.0.0.1", 8091);
  • The series sent are:

    foo x=10i
    bar y=10.30
    

Query example

  • And you can query series by according to the following example.

    influxdb_cpp::server_info si("127.0.0.1", 8086, "db", "usr", "pwd");
    
    string resp;
    influxdb_cpp::query(resp, "select * from t", si);
  • You can use xpjson to parse the result refer to issue #3.

Remarks for Windows

TODO

  • Add more test cases.
  • Supports DSN initializatin for server_info.
  • Do not need to connect every time.

Misc

  • Please feel free to use influxdb-cpp.
  • Looking forward to your suggestions.
  • If your project is using influxdb-cpp, you can show your project or company here by creating a issue or let me know.

influxdb's People

Contributors

cicicici avatar

Stargazers

Dmitry Ledentsov avatar

Watchers

 avatar

Forkers

karimzahrouni

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.