您的位置:首页 > 健康 > 美食 > pageadmin好用吗_秦皇岛海三建设_手机助手_百度seo sem

pageadmin好用吗_秦皇岛海三建设_手机助手_百度seo sem

2024/12/27 22:01:29 来源:https://blog.csdn.net/qq_28919337/article/details/143383078  浏览:    关键词:pageadmin好用吗_秦皇岛海三建设_手机助手_百度seo sem
pageadmin好用吗_秦皇岛海三建设_手机助手_百度seo sem

目录

0、版本号

1、登录页面

2、账号基本信息

3、数据库案例

4、可视化

5、java案例


0、版本号

InfluxDB v2.4.0

1、登录页面

http://127.0.0.1:8086/signin

账号:自己账号 密码:自己密码

2、账号基本信息

查看用户id和组织id!!很重要 需要在作为参数请求接口

3、数据库案例

4、可视化

5、java案例

1、pom

       <dependency><groupId>com.influxdb</groupId><artifactId>influxdb-client-java</artifactId><version>6.11.0</version></dependency>

2、初始化WriteApiBlocking


import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.WriteApiBlocking;
import com.influxdb.client.domain.WritePrecision;
import org.chameleon.threadpool.monitor.PoolCollectData;import java.util.List;public class InfluxdbAssign {private final WriteApiBlocking writeApi;public InfluxdbAssign() {writeApi = InfluxDBClientFactory.create(Constant.INFLUXDB_URL,Constant.INFLUXDB_TOKEN,Constant.INFLUXDB_ORG,Constant.INFLUXDB_BUCKET).getWriteApiBlocking();}

3、写入                              

package example;import java.time.Instant;
import java.util.List;import com.influxdb.annotations.Column;
import com.influxdb.annotations.Measurement;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.QueryApi;
import com.influxdb.client.WriteApiBlocking;
import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;
import com.influxdb.query.FluxRecord;
import com.influxdb.query.FluxTable;public class InfluxDB2Example {private static char[] token = "my-token".toCharArray();private static String org = "my-org";private static String bucket = "my-bucket";public static void main(final String[] args) {InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://localhost:8086", token, org, bucket);//// 获取写的api//WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();//// 写数据point的方式//Point point = Point.measurement("temperature").addTag("location", "west").addField("value", 55D).time(Instant.now().toEpochMilli(), WritePrecision.MS);writeApi.writePoint(point);//// Write by协议的方式写//writeApi.writeRecord(WritePrecision.NS, "temperature,location=north value=60.0");//// Write by 对象的方式写!!!推荐//Temperature temperature = new Temperature();temperature.location = "south";temperature.value = 62D;temperature.time = Instant.now();writeApi.writeMeasurement( WritePrecision.NS, temperature);//// Q查询数据//String flux = "from(bucket:\"my-bucket\") |> range(start: 0)";QueryApi queryApi = influxDBClient.getQueryApi();List<FluxTable> tables = queryApi.query(flux);for (FluxTable fluxTable : tables) {List<FluxRecord> records = fluxTable.getRecords();for (FluxRecord fluxRecord : records) {System.out.println(fluxRecord.getTime() + ": " + fluxRecord.getValueByKey("_value"));}}influxDBClient.close();}对应的POJO@Measurement(name = "temperature")private static class Temperature {@Column(tag = true)String location;@ColumnDouble value;@Column(timestamp = true)Instant time;}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com