-
Notifications
You must be signed in to change notification settings - Fork 907
[Merged by Bors] - Monitoring service api #2251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 21 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
ac39e8f
Add scaffolding
pawanjay176 e6ca232
Add additional eth1 metrics
pawanjay176 0ad7cc8
Add explorer metric types
pawanjay176 fb49e4c
Add simple conversion
pawanjay176 40b3a3a
Add a json prometheus encoder
pawanjay176 97b0ba0
Add additional system and process metrics
pawanjay176 1ed5bf4
Add a beacon_process endpoint on metrics server
pawanjay176 c391d24
Fix metric names; additional metrics
pawanjay176 31d54e0
Test BeaconProcess deserialisation
pawanjay176 b9a681e
Move JsonEncoder to separate module
pawanjay176 cc9132e
Test ValidatorProcess deserialisation
pawanjay176 2389788
Add basic client; test functionality
pawanjay176 30e3dd2
Post metrics data to remote endpoint
pawanjay176 726a1d4
Return metrics based on ProcessType
pawanjay176 9ab47da
Add cli options for explorer metrics
pawanjay176 b413336
Add better logs and comment
pawanjay176 a657e72
Minor fixes
pawanjay176 b86105e
Add explorer metrics cli options to vc
pawanjay176 ea99864
Fix fallback configured metric
pawanjay176 99586de
Fix validator config
pawanjay176 d50d5da
Appease clippy
pawanjay176 a89d96f
Merge branch 'unstable' into explorer-api
pawanjay176 f1a2e67
Merge branch 'unstable' into explorer-api
pawanjay176 671899a
Move validator count metrics updation
pawanjay176 6dbfe59
Add a NOTIFIER_HEAD_SLOT metric
pawanjay176 5681213
Gather metrics internally instead of hitting http endpoints
pawanjay176 bad59b0
Fix beacon config
pawanjay176 b9e2c02
Fix validator config
pawanjay176 8b0f55f
Added libp2p beacon metrics
pawanjay176 0d1e9ab
Remove explorer endpoints from metric servers
pawanjay176 581f27f
Minor fixes
pawanjay176 b3bbbbe
Fix incorrect names on serialize
pawanjay176 0f8c126
Merge branch 'unstable' into explorer-api
pawanjay176 af10308
Use serde_json::Value for beacon and validator specific metrics
pawanjay176 8cdf66b
Remove json encoder
pawanjay176 2f60e1f
Add comments
pawanjay176 3ecb965
Add eth1 and eth2 fallback connected metrics
pawanjay176 fdfdbe4
Minor fixes
pawanjay176 a89e8b2
Lint
pawanjay176 fe6d2fa
Align to spec
pawanjay176 1296a3c
Use correct json types
pawanjay176 3a13460
Address review comments
pawanjay176 988fae6
Address more review comments
pawanjay176 0c5e192
Merge branch 'unstable' into explorer-api
pawanjay176 845f22f
Rename explorer to monitoring
pawanjay176 d55da59
Fix ETH2_FALLBACK_CONNECTED
pawanjay176 d118364
Fix formatting
pawanjay176 3565d57
Fix lint
pawanjay176 b415641
Fix unsafe iteration
pawanjay176 3708f33
Update version number string
pawanjay176 99c4338
Address review comments
pawanjay176 78a2b23
Merge branch 'unstable' into explorer-api
pawanjay176 4902f59
Merge branch 'unstable' into explorer-api
pawanjay176 660285a
Use sensitive url
pawanjay176 36aa77c
Use std function for OS; use resident memory instead of virtual
pawanjay176 c068c17
Fix cpu time metric
pawanjay176 10673d9
Fix metric in api
pawanjay176 81e1b51
Update docs
pawanjay176 d018330
Address review comments
pawanjay176 ac5d90e
Merge branch 'unstable' into explorer-api
pawanjay176 18ea6c3
Fix linux imports
pawanjay176 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,67 @@ | ||
use crate::Context; | ||
use beacon_chain::BeaconChainTypes; | ||
use lighthouse_metrics::{json_encoder::JsonEncoder, Encoder}; | ||
|
||
pub use lighthouse_metrics::*; | ||
|
||
/// Process names which need to be encoded | ||
/// Note: Only Gauge and Counter metrics can be encoded. | ||
pub const BEACON_PROCESS_METRICS: &[&str] = &[ | ||
"cpu_process_seconds_total", | ||
"process_virtual_memory_bytes", | ||
"sync_eth1_fallback_configured", | ||
"sync_eth1_connected", | ||
"store_disk_db_size", | ||
"libp2p_peer_connected_peers_total", | ||
"beacon_head_state_slot", | ||
"sync_eth2_synced", | ||
]; | ||
|
||
pub fn gather_required_metrics<T: BeaconChainTypes>( | ||
ctx: &Context<T>, | ||
) -> std::result::Result<String, String> { | ||
let mut buffer = vec![]; | ||
let encoder = JsonEncoder::new( | ||
BEACON_PROCESS_METRICS | ||
.iter() | ||
.map(|m| m.to_string()) | ||
.collect(), | ||
); | ||
|
||
// There are two categories of metrics: | ||
// | ||
// - Dynamically updated: things like histograms and event counters that are updated on the | ||
// fly. | ||
// - Statically updated: things which are only updated at the time of the scrape (used where we | ||
// can avoid cluttering up code with metrics calls). | ||
// | ||
// The `lighthouse_metrics` crate has a `DEFAULT_REGISTRY` global singleton (via `lazy_static`) | ||
// which keeps the state of all the metrics. Dynamically updated things will already be | ||
// up-to-date in the registry (because they update themselves) however statically updated | ||
// things need to be "scraped". | ||
// | ||
// We proceed by, first updating all the static metrics using `scrape_for_metrics(..)`. Then, | ||
// using `lighthouse_metrics::gather(..)` to collect the global `DEFAULT_REGISTRY` metrics into | ||
// a string that can be returned via HTTP. | ||
|
||
if let Some(beacon_chain) = ctx.chain.as_ref() { | ||
slot_clock::scrape_for_metrics::<T::EthSpec, T::SlotClock>(&beacon_chain.slot_clock); | ||
beacon_chain::scrape_for_metrics(beacon_chain); | ||
} | ||
|
||
if let (Some(db_path), Some(freezer_db_path)) = | ||
(ctx.db_path.as_ref(), ctx.freezer_db_path.as_ref()) | ||
{ | ||
store::scrape_for_metrics(db_path, freezer_db_path); | ||
} | ||
|
||
eth2_libp2p::scrape_discovery_metrics(); | ||
|
||
warp_utils::metrics::scrape_process_health_metrics(); | ||
|
||
let metrics = lighthouse_metrics::gather(); | ||
|
||
encoder.encode(&metrics, &mut buffer).unwrap(); | ||
|
||
String::from_utf8(buffer).map_err(|e| format!("Failed to encode prometheus info: {:?}", e)) | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -143,6 +143,24 @@ pub fn get_config<E: EthSpec>( | |
client_config.http_metrics.allow_origin = Some(allow_origin.to_string()); | ||
} | ||
|
||
/* | ||
* Explorer metrics | ||
*/ | ||
if cli_args.is_present("explorer-metrics") { | ||
let explorer_endpoint = cli_args | ||
.value_of("explorer-address") | ||
.expect("guaranteed by clap") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just return an error with some useful text here, it'll be nicer than a |
||
.to_string(); | ||
client_config.explorer_metrics = Some(explorer_api::Config { | ||
beacon_endpoint: Some(format!( | ||
"http://{}:{}", | ||
client_config.http_metrics.listen_addr, client_config.http_metrics.listen_port | ||
)), | ||
validator_endpoint: None, | ||
explorer_endpoint, | ||
}); | ||
} | ||
|
||
// Log a warning indicating an open HTTP server if it wasn't specified explicitly | ||
// (e.g. using the --staking flag). | ||
if cli_args.is_present("staking") { | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.