index.html 10.9 KB
Newer Older
S
StoneT2000 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<!DOCTYPE html><html lang='en'><head><title>Documentation | Taos Data</title><meta name='description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.'><meta name='keywords' content='TDengine, Big Data, Open Source, IoT, Connected Cars, Industrial IoT, time-series database, caching, stream computing, message queuing, IT infrastructure monitoring, application performance monitoring, Internet of Things,TAOS Data, Documentation, programming, coding, syntax, frequently asked questions, questions, faq'><meta name='title' content='Documentation | Taos Data'><meta property='og:site_name' content='Taos Data'/><meta property='og:title' content='Documentation | Taos Data'/><meta property='og:type' content='article'/><meta property='og:url' content='https://www.taosdata.com/en/documentation/connections-with-other-tools/index.php'/><meta property='og:description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.' /><link rel='canonical' href='https://www.taosdata.com/en/documentation/connections-with-other-tools/index.php'/><script src='../lib/jquery-3.4.1.min.js' type='application/javascript'></script><link href='../lib/bootstrap.min.css' rel='stylesheet'><link href='../styles/base.min.css' rel='stylesheet'><link rel='stylesheet' href='../lib/docs/taosdataprettify.css'><link rel='stylesheet' href='../lib/docs/docs.css'><script src='../lib/docs/prettify.js'></script><script src='../lib/docs/prettyprint-sql.js'></script></head><body><script>$('#documentation-href').addClass('active')</script><div class='container-fluid'><main class='content-wrapper'><section class='documentation'><a href='../index.html'>Back</a><h1>Connect with other tools</h1>
<a class='anchor' id='Telegraf'></a><h2>Telegraf</h2>
<p>TDengine is easy to integrate with <a href="https://www.influxdata.com/time-series-platform/telegraf/">Telegraf</a>, an open-source server agent for collecting and sending metrics and events, without more development.</p>
<a class='anchor' id='Install-Telegraf'></a><h3>Install Telegraf</h3>
<p>At present, TDengine supports Telegraf newer than version 1.7.4. Users can go to the <a href="https://portal.influxdata.com/downloads">download link</a> and choose the proper package to install on your system.</p>
<a class='anchor' id='Configure-Telegraf'></a><h3>Configure Telegraf</h3>
<p>Telegraf is configured by changing items in the configuration file <em>/etc/telegraf/telegraf.conf</em>.</p>
<p>In <strong>output plugins</strong> section,add <em>[[outputs.http]]</em> iterm: </p>
<ul>
<li><em>url</em>: http://ip:6020/telegraf/udb, in which <em>ip</em> is the IP address of any node in TDengine cluster. Port 6020 is the RESTful APT port used by TDengine. <em>udb</em> is the name of the database to save data, which needs to create beforehand.</li>
<li><em>method</em>: "POST" </li>
<li><em>username</em>: username to login TDengine</li>
<li><em>password</em>: password to login TDengine </li>
<li><em>data_format</em>: "json"</li>
<li><em>json_timestamp_units</em>: "1ms"</li>
</ul>
<p>In <strong>agent</strong> part:</p>
<ul>
<li>hostname: used to distinguish different machines. Need to be unique.</li>
<li>metric_batch_size: 30,the maximum number of records allowed to write in Telegraf. The larger the value is, the less frequent requests are sent. For TDengine, the value should be less than 50.</li>
</ul>
<p>Please refer to the <a href="https://docs.influxdata.com/telegraf/v1.11/">Telegraf docs</a> for more information.</p>
<a class='anchor' id='Grafana'></a><h2>Grafana</h2>
<p><a href="https://grafana.com">Grafana</a> is an open-source system for time-series data display. It is easy to integrate TDengine and Grafana to build a monitor system. Data saved in TDengine can be fetched and shown on the Grafana dashboard.</p>
<a class='anchor' id='Install-Grafana'></a><h3>Install Grafana</h3>
<p>For now, TDengine only supports Grafana newer than version 5.2.4. Users can go to the <a href="https://grafana.com/grafana/download">Grafana download page</a> for the proper package to download.</p>
<a class='anchor' id='Configure-Grafana'></a><h3>Configure Grafana</h3>
<p>TDengine Grafana plugin is in the <em>/usr/local/taos/connector/grafana</em> directory.
Taking Centos 7.2 as an example, just copy TDengine directory to <em>/var/lib/grafana/plugins</em> directory and restart Grafana.</p>
<a class='anchor' id='Use-Grafana'></a><h3>Use Grafana</h3>
<p>Users can log in the Grafana server (username/password:admin/admin) through localhost:3000 to configure TDengine as the data source. As is shown in the picture below, TDengine as a data source option is shown in the box:</p>
<p><img src="../assets/clip_image001.png" alt="img" /></p>
<p>When choosing TDengine as the data source, the Host in HTTP configuration should be configured as the IP address of any node of a TDengine cluster. The port should be set as 6020. For example, when TDengine and Grafana are on the same machine, it should be configured as _http://localhost:6020. </p>
<p>Besides, users also should set the username and password used to log into TDengine. Then click <em>Save&Test</em> button to save.</p>
<p><img src="../assets/clip_image001-2474914.png" alt="img" /></p>
<p>Then, TDengine as a data source should show in the Grafana data source list.</p>
<p><img src="../assets/clip_image001-2474939.png" alt="img" /></p>
<p>Then, users can create Dashboards in Grafana using TDengine as the data source:</p>
<p><img src="../assets/clip_image001-2474961.png" alt="img" /></p>
<p>Click <em>Add Query</em> button to add a query and input the SQL command you want to run in the <em>INPUT SQL</em> text box. The SQL command should expect a two-row, multi-column result, such as <em>SELECT count(*) FROM sys.cpu WHERE ts>=from and ts<to interval(interval)</em>, in which, <em>from</em>, <em>to</em> and <em>inteval</em> are TDengine inner variables representing query time range and time interval.</p>
<p><em>ALIAS BY</em> field is to set the query alias. Click <em>GENERATE SQL</em> to send the command to TDengine:</p>
<p><img src="../assets/clip_image001-2474987.png" alt="img" /></p>
<p>Please refer to the <a href="https://grafana.com/docs/">Grafana official document</a> for more information about Grafana.</p>
<a class='anchor' id='Matlab'></a><h2>Matlab</h2>
<p>Matlab can connect to and retrieve data from TDengine by TDengine JDBC Driver.</p>
<a class='anchor' id='MatLab-and-TDengine-JDBC-adaptation'></a><h3>MatLab and TDengine JDBC adaptation</h3>
<p>Several steps are required to adapt Matlab to TDengine. Taking adapting Matlab2017a on Windows10 as an example:</p>
<ol>
<li>Copy the file <em>JDBCDriver-1.0.0-dist.jar</em> in TDengine package to the directory <em>${matlab_root}\MATLAB\R2017a\java\jar\toolbox</em></li>
<li>Copy the file <em>taos.lib</em> in TDengine package to <em>${matlab</em> root <em>dir}\MATLAB\R2017a\lib\win64</em></li>
<li>Add the .jar package just copied to the Matlab classpath. Append the line below as the end of the file of <em>${matlab</em> root <em>dir}\MATLAB\R2017a\toolbox\local\classpath.txt</em></li>
</ol>
<p><code>$matlabroot/java/jar/toolbox/JDBCDriver-1.0.0-dist.jar</code></p>
<ol start="4">
<li>Create a file called <em>javalibrarypath.txt</em> in directory <em>${user_home}\AppData\Roaming\MathWorks\MATLAB\R2017a_, and add the _taos.dll</em> path in the file. For example, if the file <em>taos.dll</em> is in the directory of <em>C:\Windows\System32</em>,then add the following line in file <em>javalibrarypath.txt</em>:</li>
</ol>
<p><code>C:\Windows\System32</code></p>
<a class='anchor' id='TDengine-operations-in-Matlab'></a><h3>TDengine operations in Matlab</h3>
<p>After correct configuration, open Matlab:</p>
<ul>
<li><p>build a connection:</p>
<p><code>conn = database(‘db’, ‘root’, ‘taosdata’, ‘com.taosdata.jdbc.TSDBDriver’, ‘jdbc:TSDB://127.0.0.1:0/’)</code></p></li>
<li><p>Query:</p>
<p><code>sql0 = [‘select * from tb’]</code></p>
<p><code>data = select(conn, sql0);</code></p></li>
<li><p>Insert a record:</p>
<p><code>sql1 = [‘insert into tb values (now, 1)’]</code></p>
<p><code>exec(conn, sql1)</code></p></li>
</ul>
<p>Please refer to the file <em>examples\Matlab\TDengineDemo.m</em> for more information.</p>
<a class='anchor' id='R'></a><h2>R</h2>
<p>Users can use R language to access the TDengine server with the JDBC interface. At first, install JDBC package in R:</p>
<pre><code class="R language-R">install.packages('rJDBC', repos='http://cran.us.r-project.org')</code></pre>
<p>Then use <em>library</em> function to load the package:</p>
<pre><code class="R language-R">library('RJDBC')</code></pre>
<p>Then load the TDengine JDBC driver:</p>
<pre><code class="R language-R">drv&lt;-JDBC("com.taosdata.jdbc.TSDBDriver","JDBCDriver-1.0.0-dist.jar", identifier.quote="\"")</code></pre>
<p>If succeed, no error message will display. Then use the following command to try a database connection:</p>
<pre><code class="R language-R">conn&lt;-dbConnect(drv,"jdbc:TSDB://192.168.0.1:0/?user=root&amp;password=taosdata","root","taosdata")</code></pre>
<p>Please replace the IP address in the command above to the correct one. If no error message is shown, then the connection is established successfully. TDengine supports below functions in <em>RJDBC</em> package:</p>
<ul>
<li><em>dbWriteTable(conn, "test", iris, overwrite=FALSE, append=TRUE)</em>: write the data in a data frame <em>iris</em> to the table <em>test</em> in the TDengine server. Parameter <em>overwrite</em> must be <em>false</em>. <em>append</em> must be <em>TRUE</em> and the schema of the data frame <em>iris</em> should be the same as the table <em>test</em>.</li>
<li><em>dbGetQuery(conn, "select count(*) from test")</em>: run a query command</li>
<li><em>dbSendUpdate(conn, "use db")</em>: run any non-query command.</li>
<li><em>dbReadTable(conn, "test"</em>): read all the data in table <em>test</em></li>
<li><em>dbDisconnect(conn)</em>: close a connection</li>
<li><em>dbRemoveTable(conn, "test")</em>: remove table <em>test</em></li>
</ul>
<p>Below functions are <strong>not supported</strong> currently:</p>
<ul>
<li><em>dbExistsTable(conn, "test")</em>: if talbe <em>test</em> exists</li>
<li><em>dbListTables(conn)</em>: list all tables in the connection</li>
</ul><a href='../index.html'>Back</a></section></main></div><?php include($s.'/footer.php'); ?><script>$('pre').addClass('prettyprint linenums');PR.prettyPrint()</script><script src='lib/docs/liner.js'></script></body></html>