Skip to content

Commit 8d96520

Browse files
m-kusdroserasprout
andauthored
Docs: article about monitoring endpoints (#496)
Co-authored-by: Lev Gorodetskiy <[email protected]>
1 parent 0c3c588 commit 8d96520

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* [Prometheus integration](deployment/prometheus.md)
3838
* [Logging](deployment/logging.md)
3939
* [Backup and restore](deployment/backups.md)
40+
* [Monitoring](deployment/monitoring.md)
4041
* [F.A.Q.](faq.md)
4142
* [Troubleshooting](troubleshooting.md)
4243
* [Contribution guide](CONTRIBUTING.md)

docs/deployment/monitoring.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Monitoring
2+
3+
In order to perform up-to-date and freshness checks, DipDup provides a standard REST endpoint you can use together with Betteruptime or similar services that can search for a keyword in the response.
4+
5+
This check basically says that DipDup is not stuck and keeps receiving new data (last known block timestamp is not older than **three minutes** from now).
6+
Note that this is not enough to ensure everything works as expected, but it can at least cover the cases when there is an issue with the datasource or your indexer stops working due to an exception.
7+
8+
### URI format
9+
10+
```
11+
https://<your-indexer-host>/api/rest/dipdup_head_status?name=<datasource-uri>
12+
```
13+
14+
If you have camel case enabled in the Hasura config:
15+
16+
```
17+
https://<your-indexer-host>/api/rest/dipdupHeadStatus?name=<datasource-uri>
18+
```
19+
20+
For example:
21+
* [https://domains.dipdup.net/api/rest/dipdup_head_status?name=https://api.tzkt.io](https://domains.dipdup.net/api/rest/dipdup_head_status?name=https://api.tzkt.io)
22+
* [https://juster.dipdup.net/api/rest/dipdupHeadStatus?name=https://api.tzkt.io](https://domains.dipdup.net/api/rest/dipdup_head_status?name=https://api.tzkt.io)
23+
24+
### Response
25+
26+
If the (latest block) head subscription state was updated less than **three minutes** ago, everything is **OK**:
27+
28+
```json
29+
{
30+
"dipdup_head_status": [
31+
{
32+
"status": "OK"
33+
}
34+
]
35+
}
36+
```
37+
38+
Otherwise, the state is considered **OUTDATED**:
39+
40+
```json
41+
{
42+
"dipdup_head_status": [
43+
{
44+
"status": "OUTDATED"
45+
}
46+
]
47+
}
48+
```
49+
50+
### Custom checks
51+
52+
The default check looks like the following:
53+
54+
```sql
55+
CREATE
56+
OR REPLACE VIEW dipdup_head_status AS
57+
SELECT
58+
name,
59+
CASE
60+
WHEN timestamp < NOW() - interval '3 minutes' THEN 'OUTDATED'
61+
ELSE 'OK'
62+
END AS status
63+
FROM
64+
dipdup_head;
65+
```
66+
67+
You can also create your custom alert endpoints using SQL views and functions and then converting them to Hasura REST endpoints.
68+
69+
> 💡 **SEE ALSO**
70+
>
71+
> * {{ #summary advanced/sql.md}}
72+
> * {{ #summary graphql/rest.md}}

0 commit comments

Comments
 (0)