Yang, Tong 6182f91ba8 MRS component operation guide_normal 2.0.38.SP20 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2022-12-09 14:55:21 +00:00

48 lines
4.4 KiB
HTML

<a name="mrs_01_0585"></a><a name="mrs_01_0585"></a>
<h1 class="topictitle1">Creating a Table and Associating It with OpenTSDB</h1>
<div id="body1589421621259"><div class="section" id="mrs_01_0585__section14297175215515"><h4 class="sectiontitle">Function</h4><p id="mrs_01_0585__p178721747183615">MRS Spark can be used to access the data source of OpenTSDB, create and associate tables in the Spark, and query and insert the OpenTSDB data.</p>
<p id="mrs_01_0585__p1943211523517">Use the <strong id="mrs_01_0585__b0274015135618">CREATE TABLE</strong> command to create a table and associate it with an existing metric in OpenTSDB.</p>
<div class="note" id="mrs_01_0585__note18300165275119"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_0585__p10432152135112">If no metric exists in OpenTSDB, an error will be reported when the corresponding table is queried.</p>
</div></div>
</div>
<div class="section" id="mrs_01_0585__section7314752195113"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="mrs_01_0585__screen1850205313">CREATE TABLE [IF NOT EXISTS] OPENTSDB_TABLE_NAME USING OPENTSDB OPTIONS (
'metric' = 'METRIC_NAME',
'tags' = 'TAG1,TAG2'
);</pre>
</div>
<div class="section" id="mrs_01_0585__section1432961213524"><h4 class="sectiontitle">Keyword</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_0585__table103551812185212" frame="border" border="1" rules="all"><thead align="left"><tr id="mrs_01_0585__row1442312125528"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.3.2.1.3.1.1"><p id="mrs_01_0585__p194231112205210"><strong id="mrs_01_0585__b242310129525">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.3.2.1.3.1.2"><p id="mrs_01_0585__p54231712175216"><strong id="mrs_01_0585__b11423151217520">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_0585__row1842411285212"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.3.1.1 "><p id="mrs_01_0585__p12424212145211">metric</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.3.1.2 "><p id="mrs_01_0585__p74241012185219">Indicates the name of the metric in OpenTSDB corresponding to the table to be created.</p>
</td>
</tr>
<tr id="mrs_01_0585__row16424612185210"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.3.1.1 "><p id="mrs_01_0585__p16424612135220">tags</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.3.1.2 "><p id="mrs_01_0585__p19424161275219">Indicates the tags corresponding to the metric. The tags are used for classification, filtering, and quick retrieval. You can set 1 to 8 tags, which are separated by commas (,). The parameter value includes values of all tagKs in the corresponding metric.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_0585__section15363201265210"><h4 class="sectiontitle">Precautions</h4><p id="mrs_01_0585__p842411212522">When creating a table, you do not need to specify the <strong id="mrs_01_0585__b71860161806">timestamp</strong> and <strong id="mrs_01_0585__b11914162018">value</strong> fields. The system automatically builds the following fields based on the specified tags. The fields <strong id="mrs_01_0585__b3192191615018">TAG1</strong> and <strong id="mrs_01_0585__b1519261619010">TAG2</strong> are specified by tags.</p>
<ul id="mrs_01_0585__ul154241512105218"><li id="mrs_01_0585__li042411123524">TAG1 String</li><li id="mrs_01_0585__li842461213526">TAG2 String</li><li id="mrs_01_0585__li104241412105216">timestamp Timestamp</li><li id="mrs_01_0585__li15424212105214">value double</li></ul>
</div>
<div class="section" id="mrs_01_0585__section11370151213522"><h4 class="sectiontitle">Example</h4><p id="mrs_01_0585__p4373163111347">Create table <strong id="mrs_01_0585__b158511411807">opentsdb_table</strong> and associate it with metric <strong id="mrs_01_0585__b199014111017">city.temp</strong> of the OpenTSDB component.</p>
<pre class="screen" id="mrs_01_0585__screen3713151739">CREATE table opentsdb_table using opentsdb OPTIONS ('metric'='city.temp', 'tags'='city,location');</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0584.html">Interconnecting Spark with OpenTSDB</a></div>
</div>
</div>