Add /node/health endpoint (#1197)

* Start adding health endpoint

* Use psutil more

* Add get_health test

* Expose health to Prom

* Update comments

* Add /node/health to docs

* Update Prom naming
This commit is contained in:
Paul Hauner
2020-05-28 11:24:24 +10:00
committed by GitHub
parent 58a9f979e0
commit ea4a52984c
9 changed files with 181 additions and 4 deletions

View File

@@ -19,7 +19,7 @@ use url::Url;
pub use operation_pool::PersistedOperationPool;
pub use proto_array_fork_choice::core::ProtoArray;
pub use rest_types::{
CanonicalHeadResponse, Committee, HeadBeaconBlock, IndividualVotesRequest,
CanonicalHeadResponse, Committee, HeadBeaconBlock, Health, IndividualVotesRequest,
IndividualVotesResponse, SyncingResponse, ValidatorDutiesRequest, ValidatorDutyBytes,
ValidatorRequest, ValidatorResponse, ValidatorSubscription,
};
@@ -612,6 +612,12 @@ impl<E: EthSpec> Node<E> {
client.json_get(url, vec![]).await
}
pub async fn get_health(&self) -> Result<Health, Error> {
let client = self.0.clone();
let url = self.url("health")?;
client.json_get(url, vec![]).await
}
pub async fn syncing_status(&self) -> Result<SyncingResponse, Error> {
let client = self.0.clone();
let url = self.url("syncing")?;