Updated on 2024-08-16 GMT+08:00

Configuring OpenTSDB Parameters

  1. Before executing the sample code, you must change the values of the following parameters in opentsdb.properties in the resources directory of the sample code project.

    tsd_hostname = node-ana-coreYQnTx
    tsd_port = 4242
    tsd_protocol = https
    • tsd_hostname: Modify this parameter to the host name or IP address of the TSD instance that connects to the OpenTSDB service.
      • If the current running environment and the OpenTSDB installation environment are in the same VPC, you can use either the IP address or host name of the connected TSD instance.
      • If the current running environment and the OpenTSDB installation environment are in different VPCs, you can only use the host name to access the environment. In addition, you need to bind an EIP to the connected TSD instance, and configure the EIP and the host name of the TSD instance in the hosts file. The file path is /etc/hosts on Linux and C:\Windows\System32\drivers\etc\hosts on Windows.

      For example, if the host name of the TSD instance is node-ana-corexxqm and the corresponding EIP is 100.94.10.10, enter the following information:

      100.94.10.10 node-ana-coreYQnTx
    • tsd_port: TSD port. The default value is 4242.
    • tsd_protocol: request protocol. The default value is https.

  2. (Optional) If the sample project is not used, add the following dependencies to the pom.xml file of your project:

    • guava
      <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
      <dependency>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
          <version>18.0</version>
      </dependency>
    • gson
      <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.2.4</version>
      </dependency>
    • httpcore
      <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
      <dependency>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
          <version>4.4.4</version>
      </dependency>
    • httpclient
      <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
      <dependency>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
          <version>4.5.2</version>
      </dependency>

  3. Set a timeout interval for each HTTP request as follows:

    public static void addTimeout(HttpRequestBase req) {
      RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000)
          .setConnectionRequestTimeout(10000).setSocketTimeout(60000).build();
      req.setConfig(requestConfig);
    }