Help Center/ Cloud Search Service/ Best Practices/ Cluster Access/ Accessing a Cluster Using cURL Commands
Updated on 2023-03-29 GMT+08:00

Accessing a Cluster Using cURL Commands

If the CSS cluster and ECS are in the same VPC, you can run cURL commands on the ECS to directly access the Elasticsearch cluster. This method is mainly used to check whether the client that accesses the cluster can be connected to Elasticserach nodes.

Prerequisites

  • The CSS cluster is available.
  • An ECS that meets the following requirements is available:
    • The ECS and the CSS cluster must be in the same VPC to ensure network connectivity.
    • The security group of the ECS must be the same as that of the CSS cluster.

      If they are different, change the ECS security group, or configure the inbound and outbound rules of the group to allow access from all the security groups of the cluster. For details, see .

    For details about how to use the ECS, see .

Procedure

  1. Obtain the private network address of the cluster. It is used to access the cluster.
    1. In the navigation pane on the left, choose Clusters.
    2. In the cluster list, select a cluster, and obtain and record its Private Network Address. Format: <host>:<port> or <host>:<port>,<host>:<port>

      If the cluster has only one node, the IP address and port number of only one node are displayed, for example, 10.62.179.32:9200. If the cluster has multiple nodes, the IP addresses and port numbers of all nodes are displayed, for example, 10.62.179.32:9200,10.62.179.33:9200.

  2. Run one of the following commands on the ECS to access the cluster. The access command varies according to the security mode of the cluster.
    • Cluster in non-security mode
      curl "http://<host>:<port>"
    • Cluster in security mode + HTTP
      curl -u <user>:<password> "http://<host>:<port>"
    • Cluster in security mode + HTTPS
      curl -u <user>:<password> -k "https://<host>:<port>"
    Table 1 Variables

    Variable

    Description

    <host>

    IP address of each node in the cluster. If the cluster contains multiple nodes, there will be multiple IP addresses. You can use any of them.

    <port>

    Port number for accessing a cluster node. Generally, the port number is 9200.

    <user>

    Username for accessing the cluster.

    <password>

    Password of the user.

    An access example is as follows:

    curl "http://10.62.176.32:9200"

    Information similar to the following is displayed:

    HTTP/1.1 200 OK
    content-type: application/json; charset=UTF-8
    content-length: 513
    
    {
    	"name" : "xxx-1",
    	"cluster_name" : "xxx",
    	"cluster_uuid" : "xxx_uuid",
    	"version" : {
    		"number" : "7.10.2",
    		"build_flavor" : "oss",
    		"build_type" : "tar",
    		"build_hash" : "unknown",
    		"build_date" : "unknown",
    		"build_snapshot" : true,
    		"lucene_version" : "8.7.0",
    		"minimum_wire_compatibility_version" : "6.7.0",
    		"minimum_index_compatibility_version" : "6.0.0-beta1"
    	},
    	"tagline" : "You Know, for Search"
    }

    For more commands, see the Elasticsearch documentation.