Monitor a running Appchain
Overview
This quick-start guide helps you monitor your local Appchain. Please make sure you are running a local Appchain before continuing.
Starting an Appchain launches multiple services. A few notable ones are:
- An orchestrator
- A blockchain
- Performance monitoring
We will demonstrate how you can query these services to see the status of your Appchain. Note that it may take a few minutes for the Appchain to start gathering data to display.
Orchestrator
The orchestrator utilizes MongoDB database for storing job information.
You can monitor your Appchain by connecting to the database and querying its tables. For this, you should download MongoDB Compass. Install Compass and connect it to the default address, which should be mongodb://localhost:27017
.
The connection displays four databases. Currently, we're most interested in the orchestrator database's jobs table.
Query jobs
The orchestrator is running various jobs all the time. We can query its logs to see, for example, the latest performed jobs:
- Go to the
orchestrator
database and itsjobs
table. - Under the
Documents
tab there is a query row. Go all the way right to click onOptions
. - Enter
Sort
:{ "created_at": -1 }
. - Hit
Find
.
Blockchain
Another source of data for our Appchain is the blockchain itself. You can query your Appchain's sequencer directly to retrieve information about blockchain operations.
Current block number
The Appchain's sequencer should be listening at address http://localhost:9945
. We can use Starknet's starknet_blockNumber
function to retrieve the latest block number:
curl -X POST http://localhost:9945/ -H "Content-Type: application/json" --data '{
"jsonrpc": "2.0",
"method": "starknet_blockNumber",
"params": [],
"id": 1
}'
Latest settled block number
In an Appchain, all transactions are eventually settled on some base layer.
Notes on the parameters:
- The settlement layer's node should be listening at address
http://127.0.0.1:8545
. - The verifier contract should be deployed at
0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
. - The target function is called
stateBlockNumber()
. It first has to be converted into its shortened hash value, which gives us0x35befa5d
.
Therefore, to retrieve the latest settled block number, you should run:
curl -X POST http://127.0.0.1:8545 -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"data": "0x35befa5d"
}, "latest"],
"id": 1
}'
Grafana
The Appchain utilizes Grafana for log and metrics aggregation. We will later add a detailed guide on how to set up Grafana for your Appchain. Meanwhile, here are some examples on what you can monitor.
Monitoring block information
Monitoring Appchain performance