Example #1
0
        public DeviceViewModel()
        {
            _tagViewModel = new TagViewModel();
            var influxHost = Environment.GetEnvironmentVariable("INFLUX_HOST");
            var influxKey  = Environment.GetEnvironmentVariable("INFLUX_KEY");

            _influxOrg    = Environment.GetEnvironmentVariable("INFLUX_ORG");
            _influxBucket = Environment.GetEnvironmentVariable("INFLUX_BUCKET");

            if (null == influxHost || null == influxKey || null == _influxOrg || null == _influxBucket)
            {
                Console.WriteLine("The necessary InfluxDB details have not been set in environment variables.");
                Console.WriteLine("Please see the project documentation for details: https://github.com/balenalabs-incubator/balenaLocating");
                return;
            }

            try
            {
                _influxDBClient = InfluxDBClientFactory.Create(influxHost,
                                                               influxKey.ToCharArray());
                _influxDBClient.SetLogLevel(LogLevel.Body);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Influx exception: " + ex);
                return;
            }
        }
Example #2
0
        public void LogLevelWithQueryString()
        {
            var writer = new StringWriter();

            Trace.Listeners.Add(new TextWriterTraceListener(writer));

            _client.SetLogLevel(LogLevel.Headers);

            MockServer
            .Given(Request.Create().WithPath("/api/v2/write").UsingPost())
            .RespondWith(CreateResponse("{}"));

            using (var writeApi = _client.GetWriteApi())
            {
                writeApi.WriteRecord("b1", "org1", WritePrecision.Ns,
                                     "h2o_feet,location=coyote_creek water_level=1.0 1");
            }

            StringAssert.Contains("org=org1", writer.ToString());
            StringAssert.Contains("bucket=b1", writer.ToString());
            StringAssert.Contains("precision=ns", writer.ToString());
        }
Example #3
0
        public new void SetUp()
        {
            var options = InfluxDBClientOptions.Builder
                          .CreateNew()
                          .Url(MockServerUrl)
                          .AuthenticateToken("token")
                          .Org("my-org")
                          .Build();

            _influxDbClient = InfluxDBClientFactory.Create(options);
            _influxDbClient.SetLogLevel(LogLevel.Body);
            _queryApi = _influxDbClient.GetQueryApi();
        }
        public new async Task SetUp()
        {
            _client = InfluxDBClientFactory.Create(GetInfluxDb2Url(), "my-token");
            _client.SetLogLevel(LogLevel.Body);

            // DateTime(2020, 10, 15, 8, 20, 15, DateTimeKind.Utc)
            const string sensor11 = "sensor,deployment=production,sensor_id=id-1 data=15i 1602750015";
            const string sensor21 = "sensor,deployment=production,sensor_id=id-2 data=15i 1602750015";
            // new DateTime(2020, 11, 15, 8, 20, 15, DateTimeKind.Utc)
            const string sensor12 = "sensor,deployment=production,sensor_id=id-1 data=28i 1605428415";
            const string sensor22 = "sensor,deployment=production,sensor_id=id-2 data=28i 1605428415";
            // new DateTime(2020, 11, 16, 8, 20, 15, DateTimeKind.Utc)
            const string sensor13 = "sensor,deployment=production,sensor_id=id-1 data=12i 1605514815";
            const string sensor23 = "sensor,deployment=production,sensor_id=id-2 data=12i 1605514815";
            // new DateTime(2020, 11, 17, 8, 20, 15, DateTimeKind.Utc)
            const string sensor14 = "sensor,deployment=production,sensor_id=id-1 data=89i 1605601215";
            const string sensor24 = "sensor,deployment=production,sensor_id=id-2 data=89i 1605601215";

            await _client
            .GetWriteApiAsync()
            .WriteRecordsAsync("my-bucket", "my-org", WritePrecision.S,
                               sensor11, sensor21, sensor12, sensor22, sensor13, sensor23, sensor14, sensor24);
        }