Accessing a Cluster

After a cluster is created, you can access the cluster to use Elasticsearch and perform operations, such as, defining index data, importing data, and searching for data. For more information about Elasticsearch, see the Elasticsearch Reference. You can use any of the following methods to access a cluster:

Accessing a Cluster Using Kibana on the Management Console

  1. Log in to the CSS management console.
  2. In the left navigation pane, click Clusters.
  3. On the displayed Clusters page, locate the row containing the target cluster and click Access Kibana in the Operation column.

  4. On the Kibana page that is displayed, you can create indices, query indices and documents, and analyze document fields. For details about Kibana, see Kibana. For details about how to import data to Elasticsearch, see the following sections:

Accessing a Cluster by Calling Elasticsearch APIs on the ECS That Is Located in the Same VPC as the Cluster

The ECS that you use to access the cluster by calling Elasticsearch APIs, must meet the following requirements. For details about how to create and log in to an ECS, see Logging In to a Linux ECS or Logging In to a Windows ECS.

To access a cluster by calling Elasticsearch APIs on the ECS that is located in the same VPC as the cluster, perform the following steps:

  1. Create and then log in to an ECS that meets the requirements.
  2. To access a cluster, use the private network address and port number of one node in the cluster. You can obtain the private network addresses of nodes from the Private Network Address column in the cluster list. If there is only one node in the cluster, the private network address and port number of this node are displayed. If there are multiple nodes in the cluster, private network addresses and port numbers of all nodes are displayed.

    Assume that there are two nodes in a cluster. Value 10.62.179.32:9200 10.62.179.33:9200 indicates that the private network addresses of the two nodes are 10.62.179.32 and 10.62.179.33 respectively, and port 9200 is used to access both nodes.

  3. Run the cURL command to execute the API or call the API by using a program before accessing the cluster. For details about Elasticsearch operations and APIs, see the Elasticsearch Reference.
    For example, run the following cURL command to view the index information in the cluster. In this example, the private access IP address of one node in the cluster is 10.62.179.32 and the port number is 9200.
    • If the cluster you access has the communication encryption function enabled, you need to access the cluster using HTTPS and add -k to the cURL command.
      If communication encryption is enabled, the CSS server uses a shared self-signed certificate. In this case, the client cannot authenticate the certificate. You are advised to disable certificate verification on the client.
      curl -k 'https://10.62.179.32:9200/_cat/indices'
    • If encryption has not been enabled for the communication with the cluster, run the following command:
      curl 'http://10.62.179.32:9200/_cat/indices'

    In the preceding command, the private network address and port number of only one node in the cluster are used. If the node fails, the command will fail to be executed. If the cluster contains multiple nodes, you can replace the private network address and port number of the faulty node with those of any available node in the cluster. If the cluster contains only one node, restore the node and execute the command again.

    If encryption has not been enabled for the communication with the cluster, the command output is similar to that shown in the following figure.

    Figure 1 Command output

Accessing a Cluster Using Java API in Non-security Mode

For clusters in the non-security mode, you are advised to use use RestHighLevelClient.

Accessing a Cluster Using the Java API in Security Mode with Elasticsearch

After enabling the security mode function for Elasticsearch 7.1.1 and later versions, accessing a cluster requires the use of HTTPS and the username and password for authentication.

You need to use clusters 7.1.1 and later versions as well as related APIs if you use the Java API to access a cluster, because the TransportClient class in the earlier version cannot access a cluster using the username and password.

Two access modes are available: Create a client using either the TransportClient or RestHighLevelClient class. RestHighLevelClient is recommended.