Similar elasticsearch commands

Hi,

Is there any similar elasticsearch commands below using curl that I can use on cratedb also using curl command?

curl “$HOSTNAME:9200/_cluster/settings?pretty=true”
curl “$HOSTNAME:9200/_cat/health?v”
curl “$HOSTNAME:9200/_cat/allocation?v”
curl “$HOSTNAME”:9200/_cat/nodes?v
curl “$HOSTNAME:9200/_nodes/stats?pretty”
curl “$HOSTNAME:9200/_cat/master?v”

Thanks

1 Like

Hi,
You can use curl to get SQL queries executed against CrateDB
HTTP endpoint — CrateDB: Reference

You can then get this kind of information from sys.cluster, sys.health, sys.shards, and sys.nodes.
Take a look at System information — CrateDB: Reference for an idea of what is available.

I hope this helps, but please let us know if you have difficulties finding any specific information.

Thank you.

2 Likes

Hi,

Okay, I’ll try some commands in my test environment and paste the results here as examples

Thanks.

Cluster

curl -sSXPOST 'user:pass@node01:4200/_sql?pretty' -d '{"stmt":"select name from sys.cluster"}' | jq

{
  "cols": [
    "name"
  ],
  "rows": [
    [
      "mycluster"
    ]
  ],
  "rowcount": 1,
  "duration": 0.653828
}

Health

curl -sSXPOST 'user:pass@node01:4200/_sql?pretty' -d '{"stmt":"select health,count(*) qty from sys.health group by health"}' | jq

{
  "cols": [
    "health",
    "qty"
  ],
  "rows": [
    [
      "GREEN",
      24
    ]
  ],
  "rowcount": 1,
  "duration": 1.107071
}

Nodes

curl -sSXPOST 'user:pass@node01:4200/_sql?pretty' -d '{"stmt":"select hostname from sys.nodes order by hostname"}' | jq

{
  "cols": [
    "hostname"
  ],
  "rows": [
    [
      "node01"
    ],
    [
      "node02"
    ],
    [
      "node03"
    ]
  ],
  "rowcount": 3,
  "duration": 2.470829
}

Allocation

curl -sSXPOST 'user:pass@node01:4200/_sql?pretty' -d '{"stmt":"select decisions[2]['\''node_name'\''] node,count(*) qty from sys.allocations group by decisions[2]['\''node_name'\'']"}' | jq

{
  "cols": [
    "node",
    "qty"
  ],
  "rows": [
    [
      "node01",
      48
    ],
    [
      "node02",
      48
    ],
    [
      "node03",
      48
    ]
  ],
  "rowcount": 3,
  "duration": 8.945432
}

1 Like