github.com/prysmaticlabs/prysm@v1.4.4/shared/clientstats/types.go (about) 1 package clientstats 2 3 const ( 4 ClientName = "prysm" 5 BeaconNodeProcessName = "beaconnode" 6 ValidatorProcessName = "validator" 7 APIVersion = 1 8 ) 9 10 // APIMessage are common to all requests to the client-stats API 11 // Note that there is a "system" type that we do not currently 12 // support -- if we did APIMessage would be present on the system 13 // messages as well as validator and beaconnode, whereas 14 // CommonStats would only be part of beaconnode and validator. 15 type APIMessage struct { 16 APIVersion int `json:"version"` 17 Timestamp int64 `json:"timestamp"` // unix timestamp in milliseconds 18 ProcessName string `json:"process"` // validator, beaconnode, system 19 } 20 21 // CommonStats represent generic metrics that are expected on both 22 // beaconnode and validator metric types. This type is used for 23 // marshaling metrics to the POST body sent to the metrics collcetor. 24 // Note that some metrics are labeled NA because they are expected 25 // to be present with their zero-value when not supported by a client. 26 type CommonStats struct { 27 CPUProcessSecondsTotal int64 `json:"cpu_process_seconds_total"` 28 MemoryProcessBytes int64 `json:"memory_process_bytes"` 29 ClientName string `json:"client_name"` 30 ClientVersion string `json:"client_version"` 31 ClientBuild int64 `json:"client_build"` 32 // TODO(#8849): parse the grpc connection string to determine 33 // if multiple addresses are present 34 SyncEth2FallbackConfigured bool `json:"sync_eth2_fallback_configured"` 35 // N/A -- when multiple addresses are provided to grpc, requests are 36 // load-balanced between the provided endpoints. 37 // This is different from a "fallback" configuration where 38 // the second address is treated as a failover. 39 SyncEth2FallbackConnected bool `json:"sync_eth2_fallback_connected"` 40 APIMessage `json:",inline"` 41 } 42 43 // BeaconNodeStats embeds CommonStats and represents metrics specific to 44 // the beacon-node process. This type is used to marshal metrics data 45 // to the POST body sent to the metrics collcetor. To make the connection 46 // to client-stats clear, BeaconNodeStats is also used by prometheus 47 // collection code introduced to support client-stats. 48 // Note that some metrics are labeled NA because they are expected 49 // to be present with their zero-value when not supported by a client. 50 type BeaconNodeStats struct { 51 // TODO(#8850): add support for this after slasher refactor is merged 52 SlasherActive bool `json:"slasher_active"` 53 SyncEth1FallbackConfigured bool `json:"sync_eth1_fallback_configured"` 54 SyncEth1FallbackConnected bool `json:"sync_eth1_fallback_connected"` 55 SyncEth1Connected bool `json:"sync_eth1_connected"` 56 SyncEth2Synced bool `json:"sync_eth2_synced"` 57 DiskBeaconchainBytesTotal int64 `json:"disk_beaconchain_bytes_total"` 58 // N/A -- would require significant network code changes at this time 59 NetworkLibp2pBytesTotalReceive int64 `json:"network_libp2p_bytes_total_receive"` 60 // N/A -- would require significant network code changes at this time 61 NetworkLibp2pBytesTotalTransmit int64 `json:"network_libp2p_bytes_total_transmit"` 62 // p2p_peer_count where label "state" == "Connected" 63 NetworkPeersConnected int64 `json:"network_peers_connected"` 64 // beacon_head_slot 65 SyncBeaconHeadSlot int64 `json:"sync_beacon_head_slot"` 66 CommonStats `json:",inline"` 67 } 68 69 // ValidatorStats embeds CommonStats and represents metrics specific to 70 // the validator process. This type is used to marshal metrics data 71 // to the POST body sent to the metrics collcetor. 72 // Note that some metrics are labeled NA because they are expected 73 // to be present with their zero-value when not supported by a client. 74 type ValidatorStats struct { 75 // N/A -- TODO(#8848): verify whether we can obtain this metric from the validator process 76 ValidatorTotal int64 `json:"validator_total"` 77 // N/A -- TODO(#8848): verify whether we can obtain this metric from the validator process 78 ValidatorActive int64 `json:"validator_active"` 79 CommonStats `json:",inline"` 80 }