-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Write latest post block height to Grafana
- Loading branch information
1 parent
3ab0a84
commit adbf15f
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import fetch from "node-fetch"; | ||
import AWS from "aws-sdk"; | ||
|
||
import Metrics from "./metrics"; | ||
|
||
export const handler = async () => { | ||
const metrics = new Metrics("QueryAPI"); | ||
|
||
const response = await this.deps.fetch("https://api.near.social/index", { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
action: "post", | ||
key: "main", | ||
options: { | ||
limit: 1, | ||
order: "desc", | ||
}, | ||
}), | ||
}); | ||
|
||
const [{ blockHeight }] = await response.json(); | ||
|
||
await metrics.putBlockHeight("social.near", "posts", blockHeight); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters