Skip to content

Commit 4a95f38

Browse files
Adding subgraph health
1 parent eaf3906 commit 4a95f38

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

website/pages/en/deploying/multiple-networks.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,37 @@ A subgraph version in Studio is archived if and only if it meets the following c
237237

238238
In addition, when a new version is deployed, if the subgraph has not been published, then the N-2 version of the subgraph is archived.
239239

240-
Every subgraph affected with this policy has an option to bring the version in question back.
240+
Every subgraph affected with this policy has an option to bring the version in question back.
241+
242+
## Checking subgraph health
243+
244+
If a subgraph syncs successfully, that is a good sign that it will continue to run well forever. However, new triggers on the network might cause your subgraph to hit an untested error condition or it may start to fall behind due to performance issues or issues with the node operators.
245+
246+
Graph Node exposes a graphql endpoint which you can query to check the status of your subgraph. On the hosted service, it is available at `https://api.thegraph.com/index-node/graphql`. On a local node, it is available on port `8030/graphql` by default. The full schema for this endpoint can be found [here](https://github.com/graphprotocol/graph-node/blob/master/server/index-node/src/schema.graphql). Here is an example query that checks the status of the current version of a subgraph:
247+
248+
```graphql
249+
{
250+
indexingStatusForCurrentVersion(subgraphName: "org/subgraph") {
251+
synced
252+
health
253+
fatalError {
254+
message
255+
block {
256+
number
257+
hash
258+
}
259+
handler
260+
}
261+
chains {
262+
chainHeadBlock {
263+
number
264+
}
265+
latestBlock {
266+
number
267+
}
268+
}
269+
}
270+
}
271+
```
272+
273+
This will give you the `chainHeadBlock` which you can compare with the `latestBlock` on your subgraph to check if it is running behind. `synced` informs if the subgraph has ever caught up to the chain. `health` can currently take the values of `healthy` if no errors occurred, or `failed` if there was an error which halted the progress of the subgraph. In this case, you can check the `fatalError` field for details on this error.

0 commit comments

Comments
 (0)