Remove metrics with high cardinality (#3121)

* remove metrics with high cardinality

* imports
This commit is contained in:
Preston Van Loon
2019-08-01 12:23:52 -04:00
committed by GitHub
parent 474fd20123
commit f019e54ebb
3 changed files with 25 additions and 79 deletions

View File

@@ -280,13 +280,6 @@ func (a *Service) updateAttestation(beaconState *pb.BeaconState, attestation *et
"sourceEpoch": attestation.Data.Source.Epoch,
},
).Debug("Attestation store updated")
blockRoot := bytesutil.ToBytes32(attestation.Data.BeaconBlockRoot)
votedBlock, err := a.beaconDB.Block(blockRoot)
if err != nil {
return err
}
reportVoteMetrics(committee[i], votedBlock)
}
}
return nil

View File

@@ -1,20 +1,11 @@
package attestation
import (
"strconv"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
)
var (
validatorLastVoteGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "validators_last_vote",
Help: "Votes of validators, updated when there's a new attestation",
}, []string{
"validatorIndex",
})
totalAttestationSeen = promauto.NewGauge(prometheus.GaugeOpts{
Name: "total_seen_attestations",
Help: "Total number of attestations seen by the validators",
@@ -29,13 +20,3 @@ var (
Help: "The current size of the attestation pool",
})
)
func reportVoteMetrics(index uint64, block *ethpb.BeaconBlock) {
// Don't update vote metrics if the incoming block is nil.
if block == nil {
return
}
validatorLastVoteGauge.WithLabelValues(
"v" + strconv.Itoa(int(index))).Set(float64(block.Slot))
}

View File

@@ -1,9 +1,6 @@
package db
import (
"encoding/hex"
"strconv"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
@@ -11,30 +8,6 @@ import (
)
var (
validatorBalancesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "state_validator_balances",
Help: "Balances of validators, updated on epoch transition",
}, []string{
"validator",
})
validatorActivatedGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "state_validator_activated_epoch",
Help: "Activated epoch of validators, updated on epoch transition",
}, []string{
"validatorIndex",
})
validatorExitedGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "state_validator_exited_epoch",
Help: "Exited epoch of validators, updated on epoch transition",
}, []string{
"validatorIndex",
})
validatorSlashedGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "state_validator_slashed_epoch",
Help: "Slashed epoch of validators, updated on epoch transition",
}, []string{
"validatorIndex",
})
lastSlotGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "state_last_slot",
Help: "Last slot number of the processed state",
@@ -55,43 +28,42 @@ var (
Name: "state_active_validators",
Help: "Total number of active validators",
})
slashedValidatorsGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "state_slashed_validators",
Help: "Total slashed validators",
})
withdrawnValidatorsGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "state_withdrawn_validators",
Help: "Total withdrawn validators",
})
totalValidatorsGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "state_total_validators",
Help: "All time total validators",
})
)
func reportStateMetrics(state *pb.BeaconState) {
currentEpoch := state.Slot / params.BeaconConfig().SlotsPerEpoch
// Validator balances
for i, bal := range state.Balances {
validatorBalancesGauge.WithLabelValues(
"0x" + hex.EncodeToString(state.Validators[i].PublicKey), // Validator
).Set(float64(bal))
}
// Validator counts
var active float64
for i, v := range state.Validators {
// Track individual Validator's activation epochs
validatorActivatedGauge.WithLabelValues(
strconv.Itoa(i), //Validator index
).Set(float64(v.ActivationEpoch))
// Track individual Validator's exited epochs
validatorExitedGauge.WithLabelValues(
strconv.Itoa(i), //Validator index
).Set(float64(v.ExitEpoch))
// Track individual Validator's slashed epochs
if v.Slashed {
validatorSlashedGauge.WithLabelValues(
strconv.Itoa(i), //Validator index
).Set(float64(v.WithdrawableEpoch - params.BeaconConfig().EpochsPerSlashingsVector))
} else {
validatorSlashedGauge.WithLabelValues(
strconv.Itoa(i), //Validator index
).Set(float64(params.BeaconConfig().FarFutureEpoch))
}
// Total number of active validators
var slashed float64
var withdrawn float64
for _, v := range state.Validators {
if v.ActivationEpoch <= currentEpoch && currentEpoch < v.ExitEpoch {
active++
}
if v.Slashed {
slashed++
}
if currentEpoch >= v.ExitEpoch {
withdrawn++
}
}
activeValidatorsGauge.Set(active)
slashedValidatorsGauge.Set(slashed)
withdrawnValidatorsGauge.Set(withdrawn)
totalValidatorsGauge.Set(float64(len(state.Validators)))
// Slot number
lastSlotGauge.Set(float64(state.Slot))