zoukankan      html  css  js  c++  java
  • InfluxDB时序数据库安装与使用

    1. 下载解压文件

     2.启动服务,双击运行influxd.exe

    3.安装客户端工具(InfluxDBStudio)

     4.新建数据库

    5. NuGet -> InfluxData.Net

    using InfluxData.Net.InfluxDb.Models;
    using System;
    using System.Collections.Generic;
    
    namespace InfluxDBTest
    {
        class Program
        { 
            static void Main(string[] args)
            {
                string table = "logInfo";
                var point_model1 = new Point()
                {
                    Name = table,//表名 
                    Tags = new Dictionary<string, object>() { { "Id", "5810953" } }, // 索引
                    Fields = new Dictionary<string, object>() { { "Val", 102 } },// 字段
                    Timestamp = DateTime.UtcNow
                };
    
                var point_model2 = new Point()
                {
                    Name = table,//表名
                    Tags = new Dictionary<string, object>() { { "Id1", "5810951" }, { "Id2", "5810952" } },
                    Fields = new Dictionary<string, object>() { { "Val1", 101 }, { "Val2", 102 } },
                    Timestamp = DateTime.UtcNow
                };
    
                var queries = new[] 
                {
                    " SELECT time,Id,Val FROM " + table+ " WHERE time> now() -  24h "
                };
    
                InfluxDbHelper.Init();
    
                InfluxDbHelper.Write(point_model1);
                InfluxDbHelper.Write(point_model2);
    
                //InfluxDbHelper.Read(queries).Wait();// 异步转同步
                IList<IList<object>> result = InfluxDbHelper.Read(queries).GetAwaiter().GetResult();
                for (int i = 0; i <result.Count; i++)
                {
                    var lstTemp = result[i];
                    Console.WriteLine("time:" + lstTemp[0] + ",id:" + lstTemp[1] + ",val:" + lstTemp[2]);
    
                    //for (int j = 0; j < lstTemp.Count; j++)
                    //{
                    //    object content = lstTemp[j];
                    //    Console.WriteLine(content);
                    //}
                }
    
                Console.ReadKey();
            }
        } 
    }

    qq:505645074
  • 相关阅读:
    pyexharts教程
    elasticsearch常用查询语句
    kubelet连接apiserver报TLS错误
    k8s init.yaml
    bareapi nginx配置
    traefik配置https
    kubernetes中通过static pod部署elasticsearch生产集群
    聊天服务器架构
    使用JAX-RS的实现Jersey创建RESTful Web服务
    SpringBoot+Thymeleaf+MyBatis 实现RESTful API
  • 原文地址:https://www.cnblogs.com/chen1880/p/14804969.html
Copyright © 2011-2022 走看看