提交 961c6b5f 编写于 作者: G gccgdb1234

Merge branch 'docs-cloud' of github.com:taosdata/TDengine into docs-cloud

......@@ -12,18 +12,18 @@ This section introduces the major features, competitive advantages, typical use-
The major features are listed below:
1. While TDengine supports [using SQL to insert](/develop/insert-data/sql-writing), it also supports [Schemaless writing](/reference/schemaless/) just like NoSQL databases. TDengine also supports standard protocols like [InfluxDB LINE](/develop/insert-data/influxdb-line)[OpenTSDB Telnet](/develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](/develop/insert-data/opentsdb-json) among others.
2. TDengine supports seamless integration with third-party data collection agents like [Telegraf](/third-party/telegraf)[Prometheus](/third-party/prometheus)[StatsD](/third-party/statsd)[collectd](/third-party/collectd)[icinga2](/third-party/icinga2), [TCollector](/third-party/tcollector), [EMQX](/third-party/emq-broker), [HiveMQ](/third-party/hive-mq-broker). These agents can write data into TDengine with simple configuration and without a single line of code.
3. Support for [all kinds of queries](/develop/query-data), including aggregation, nested query, downsampling, interpolation and others.
4. Support for [user defined functions](/develop/udf).
5. Support for [caching](/develop/cache). TDengine always saves the last data point in cache, so Redis is not needed in some scenarios.
6. Support for [stream processing](../taos-sql).
7. Support for [data subscription](../taos-sql) with the capability to specify filter conditions.
2. TDengine supports seamless integration with third-party tools like [Telegraf](../data-in/telegraf)[Prometheus](../data-in/prometheus),they can write data into TDengine with simple configuration and without a single line of code.
3. Support for [time series specific queries](../taos-sql/distinguished), including aggregation, nested query, downsampling, interpolation and others.
4. Support for [user defined functions](../taos-sql/udf).
5. Support for [caching](../taos-sql/database). TDengine always saves the last data point in cache, so Redis is not needed in some scenarios.
6. Support for [stream processing](../taos-sql/stream).
7. Support for [data subscription](../taos-sql/tmq) with the capability to specify filter conditions.
8. High availability is supported by replication including multi-cloud replication.
9. Provides an interactive [command-line interface](/reference/taos-shell) for management, maintenance and ad-hoc queries.
9. Provides an interactive [command-line interface](../tools/cli) for management, maintenance and ad-hoc queries.
10. Provides many ways to [get data in](../data-in) and [get data out](../data-out) data.
11. Provides a Dashboard to monitor your running instances of TDengine.
12. Provides [connectors](../connector/) for [Java](../connector/java), [Python](../connector/python), [Go](../connector/go), [Rust](../connector/rust), and [Node.js](../connector/node).
13. Provides a [REST API](/reference/rest-api/).
13. Provides a [REST API](../develop/connect/rest-api/).
14. Supports seamless integration with [Grafana](../visual/grafana) for visualization.
15. Supports seamless integration with Google Data Studio.
......
......@@ -4,6 +4,9 @@ title: REST API
description: Communicate with TDengine Cloud Service through RESTful API
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Config
Run this command in your terminal to save the TDengine cloud token and URL as variables:
......
```rust
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
{{#include docs/examples/rust/cloud-example/examples/subscribe_demo.rs}}
```
......@@ -24,7 +24,7 @@ The following example lists all databases on the `TDengine Cloud URL` host. If y
```bash
curl -L \
-d "select name, ntables, status from information_schema.ins_databases;" \
<TDengine Service URL>/rest/sql?token=<TDengine Cloud Token>
<TDengine Cloud URL>/rest/sql?token=<TDengine Cloud Token>
```
The following return value results indicate that the verification passed.
......@@ -68,7 +68,7 @@ The following return value results indicate that the verification passed.
## HTTP request URL format
```text
http://<TDENGINE_CLOUD_URL>/rest/sql/[db_name]?token=TDENGINE_CLOUD_TOKEN
https://<TDENGINE_CLOUD_URL>/rest/sql/[db_name]?token=TDENGINE_CLOUD_TOKEN
```
Parameter Description:
......@@ -77,7 +77,7 @@ Parameter Description:
- db_name: Optional parameter specifies the default database name for the executed SQL command.
- token: used to access TDengine cloud service.
For example, `http://gw-aws.cloud.tdengine.com:80/rest/sql/test?token=xxxxxxxxx` is a URL to `gw-aws.cloud.tdengine:80` and sets the default database name to `test`.
For example, `https://gw-aws.cloud.tdengine.com:80/rest/sql/test?token=xxxxxxxxx` is a URL to `gw-aws.cloud.tdengine:80` and sets the default database name to `test`.
The HTTP request's BODY is a complete SQL command, and the data table in the SQL statement should be provided with a database prefix, e.g., `db_name.tb_name`. If the table name does not have a database prefix and the database name is not specified in the URL, the system will respond with an error because the HTTP module is a simple forwarder and has no awareness of the current DB.
......
use std::time::Duration;
use chrono::{DateTime, Local};
use taos::*;
// Query options 2, use deserialization with serde.
#[derive(Debug, serde::Deserialize)]
#[allow(dead_code)]
struct Record {
// deserialize timestamp to chrono::DateTime<Local>
ts: DateTime<Local>,
// float to f32
current: Option<f32>,
// int to i32
voltage: Option<i32>,
phase: Option<f32>,
}
async fn prepare(taos: Taos) -> anyhow::Result<()> {
let inserted = taos.exec_many([
// create child table
"CREATE TABLE `d0` USING `meters` TAGS(0, 'Los Angles')",
// insert into child table
"INSERT INTO `d0` values(now - 10s, 10, 116, 0.32)",
// insert with NULL values
"INSERT INTO `d0` values(now - 8s, NULL, NULL, NULL)",
// insert and automatically create table with tags if not exists
"INSERT INTO `d1` USING `meters` TAGS(1, 'San Francisco') values(now - 9s, 10.1, 119, 0.33)",
// insert many records in a single sql
"INSERT INTO `d1` values (now-8s, 10, 120, 0.33) (now - 6s, 10, 119, 0.34) (now - 4s, 11.2, 118, 0.322)",
]).await?;
assert_eq!(inserted, 6);
Ok(())
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let dsn = "taosws://localhost:6030";
let builder = TaosBuilder::from_dsn(dsn)?;
let taos = builder.build()?;
let db = "tmq";
// prepare database
taos.exec_many([
format!("DROP TOPIC IF EXISTS tmq_meters"),
format!("DROP DATABASE IF EXISTS `{db}`"),
format!("CREATE DATABASE `{db}`"),
format!("USE `{db}`"),
// create super table
format!("CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, `phase` FLOAT) TAGS (`groupid` INT, `location` BINARY(16))"),
// create topic for subscription
format!("CREATE TOPIC tmq_meters with META AS DATABASE {db}")
])
.await?;
let task = tokio::spawn(prepare(taos));
tokio::time::sleep(Duration::from_secs(1)).await;
// subscribe
let tmq = TmqBuilder::from_dsn("taosws://localhost:6030/?group.id=test")?;
let mut consumer = tmq.build()?;
consumer.subscribe(["tmq_meters"]).await?;
{
let mut stream = consumer.stream();
while let Some((offset, message)) = stream.try_next().await? {
// get information from offset
// the topic
let topic = offset.topic();
// the vgroup id, like partition id in kafka.
let vgroup_id = offset.vgroup_id();
println!("* in vgroup id {vgroup_id} of topic {topic}\n");
if let Some(data) = message.into_data() {
while let Some(block) = data.fetch_raw_block().await? {
// one block for one table, get table name if needed
let name = block.table_name();
let records: Vec<Record> = block.deserialize().try_collect()?;
println!(
"** table: {}, got {} records: {:#?}\n",
name.unwrap(),
records.len(),
records
);
}
}
consumer.commit(offset).await?;
}
}
consumer.unsubscribe().await;
task.await??;
Ok(())
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册