8

Is there an API for nodetool? Especially nodetool tablestats

I saw there is https://github.com/scylladb/scylla/tree/master/api/api-doc. Is this the right place to look for APIs?

SilentCanon
  • 626
  • 4
  • 11

2 Answers2

11

The Scylla server indeed has a REST API and it's documentation is at the URL you point to. You can find a Swagger UI when you start the Scylla server as well: https://docs.scylladb.com/operating-scylla/rest/.

But, please note that nodetool, for example, does not use the API directly. Instead, it talks to the Scylla JMX proxy, which is a Java process that implements Cassandra-compatible JMX API. You can still use the REST API directly, but you have to figure out the mapping between the JMX operations and the REST API yourself.

For something like nodetool tablestats, the first step is to check what JMX APIs nodetool uses:

https://github.com/scylladb/scylla-tools-java/blob/master/src/java/org/apache/cassandra/tools/nodetool/TableStats.java

The command delegates to TableStatsHolder class:

https://github.com/scylladb/scylla-tools-java/blob/master/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java#L117

which uses the ColumnFamilyStoreMBean JMX API for querying table statistics.

You can find the implementation of the JMX API in the scylla-jmx project by finding the ColumnFamilyStore class (without the MBean suffix):

https://github.com/scylladb/scylla-jmx/blob/master/src/main/java/org/apache/cassandra/db/ColumnFamilyStore.java

From that class, you can see that, for example, the ColumnFamilyStore.getSSTableCountPerLevel() method delegates to the column_family/sstables/per_level/<table name> REST API URL.

Pekka Enberg
  • 391
  • 2
  • 5
  • Something important you should know about the REST API is that, as of this writing, it is only own **inside** the node - you cannot connect to it from external machines. This is important because the there is no authentication or authorization protocol for this REST API. So the REST API will only be useful for you if you install your own agent process on a Scylla node, or use ssh to log onto the Scylla node. – Nadav Har'El Dec 24 '19 at 12:50
3

Hmm, FWIW I have a reimplementation of nodetool by using direct access to API here: https://github.com/scylladb/scylla-tools-java/pull/121

It works, but code-wise I will do some refactorings to avoid duplication, otherwise it's completely usable nodetool over REST API (which skips JMX for "tablestats")

Dharman
  • 30,962
  • 25
  • 85
  • 135
Lubos
  • 246
  • 1
  • 4