Connecting to OpenTSDB

If you enable OpenTSDB when creating a CloudTable cluster, you can access OpenTSDB through an OpenTSDB link on an ECS after the cluster is created to send HTTP requests to a resource path for data read and write.

If OpenTSDB is not enabled during cluster creation, you can enable it after the cluster is created by referring to Enabling OpenTSDB.

Using HTTP APIs to Access OpenTSDB

OpenTSDB can be accessed only using HTTP APIs. For clusters with IAM authentication disabled, OpenTSDB uses HTTP for external access. For clusters with IAM enabled, OpenTSDB uses HTTPS for external access.

HTTP has security risks and HTTPS is a secure protocol. You are advised to use HTTPS for connection.

OpenTSDB 2.3.0 is used in CloudTable and its APIs are consistent with the APIs of the open source OpenTSDB.

For more information about OpenTSDB APIs, see OpenTSDB API Introduction in the CloudTable Service Developer Guide.

Connecting to OpenTSDB

  1. Obtain an OpenTSDB link.

    Log in to the CloudTable management console and choose Cluster Mode in the left navigation pane. Locate the cluster to be viewed in the cluster list and click the cluster name. On the basic information page that is displayed, obtain the OpenTSDB link (intranet).

    Figure 1 OpenTSDB link

  2. Prepare a client operating environment.

    The OpenTSDB link is an intranet address. You need to prepare an ECS that is in the same region, AZ, VPC, subnet, and security group as the CloudTable cluster to access OpenTSDB.

    For details about how to create and log in to an ECS, see Preparing an ECS.

  3. On the ECS, access OpenTSDB.

    You can access OpenTSDB using either of the following methods:
    • Use the cURL command line tool or a REST client such as Postman to send an HTTP request to access OpenTSDB.

      For example, use the cURL command line tool to send the following request. If 200 OK is returned, it indicates that OpenTSDB has been connected. {OpenTSDB URL} is the OpenTSDB link obtained in 1.

      curl -i -X GET http://{OpenTSDB URL}/api/version

      The following provides examples of writing data and querying data:

      1. Writing data:
        curl -i -X POST -d '{"metric":"money", "timestamp":1524900283, "value":1, "tags":{"card":"card1"}}' http://{OpenTSDB URL}/api/put?sync -k -v
      2. Querying data:
        curl -i -X POST -d '{"start": 1524900283,"end": 1524900289,"queries": [{"aggregator": "sum","metric": "money"}]}' http://{OpenTSDB URL}/api/query -k -v
    • Develop an application program to call HTTP APIs to access OpenTSDB for reading and writing data.

      For details, see the following sections in the CloudTable Service Developer Guide: