Help Center > > User Guide> MRS Cluster Component Operation Guide> Using Spark> Interconnecting Spark with OpenTSDB> Creating a Table and Associating It with OpenTSDB

Creating a Table and Associating It with OpenTSDB

Updated at: Nov 06, 2019 GMT+08:00

Function

MRS Spark can be used to access the data source of OpenTSDB, create association tables in the Spark, and query and insert the OpenTSDB data.

Use the CREATE TABLE command to create a table and associate it with an existing metric in OpenTSDB.

If no metric exists in OpenTSDB, an error will be reported when the corresponding table is queried.

Syntax

CREATE TABLE [IF NOT EXISTS] OPENTSDB_TABLE_NAME   USING OPENTSDB OPTIONS (
'metric' = 'METRIC_NAME',
'tags' = 'TAG1,TAG2'
);

Keyword

Parameter

Description

metric

Name of the metric in OpenTSDB corresponding to the table to be created.

tags

Tag 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.

Precautions

When creating a table, you do not need to specify the timestamp and value fields. The system automatically builds the following fields based on the specified tags. The fields TAG1 and TAG2 are specified by tags.

  • TAG1 String
  • TAG2 String
  • timestamp Timestamp
  • value double

Example

Create table opentsdb_table table and associate it with metric city.temp of the OpenTSDB component.

CREATE table opentsdb_table using opentsdb OPTIONS ('metric'='city.temp',  'tags'='city,location');

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel