Adding epoch as a label to the doppelganger metrics

This commit is contained in:
Dadepo Aderemi
2022-05-31 15:40:17 +02:00
parent d800d949b9
commit 993a4e81e6
3 changed files with 12 additions and 7 deletions

View File

@@ -17,21 +17,23 @@ services:
BEACON_URL: localhost:8008
VC_URL: localhost:5064
restart: always
network_mode: host
ports:
- "9090:9090"
volumes:
- "prometheus:/prometheus"
grafana:
build: grafana
restart: always
network_mode: host
ports:
- "3000:3000"
volumes:
- "grafana:/var/lib/grafana"
- "../dashboards:/dashboards"
environment:
# Linux: http://localhost:9090
# MacOSX: http://host.docker.internal:9090
PROMETHEUS_URL: http://localhost:9090
PROMETHEUS_URL: http://host.docker.internal:9090
volumes:
prometheus:

View File

@@ -22,6 +22,7 @@ interface Gauge<Labels extends LabelsGeneric = never> {
interface Histogram<Labels extends LabelsGeneric = never> {
startTimer(): () => number;
startTimer(labels: Labels): () => number;
observe(value: number): void;
observe(labels: Labels, values: number): void;
@@ -321,15 +322,16 @@ export function getMetrics(register: MetricsRegister, gitData: LodestarGitData)
// Doppelganger check
doppelganger: {
checkDuration: register.histogram({
checkDuration: register.histogram<{epoch: string}>({
name: "vc_doppelganger_check_time_seconds",
help: "Time to complete a doppelganger check in seconds",
buckets: [0.5, 1, 2, 3, 6, 8],
labelNames: ["epoch"],
}),
status: register.gauge<{validatorIndex: string}>({
status: register.gauge<{epoch: string; validatorIndex: string}>({
name: "vc_doppelganger_validator_status",
help: "Statuses of doppelganger check for each validator",
labelNames: ["validatorIndex"],
labelNames: ["epoch", "validatorIndex"],
}),
},
};

View File

@@ -84,7 +84,7 @@ export class DoppelgangerService {
// Run the doppelganger protection check 75% through the last slot of this epoch. This
// *should* mean that the BN has seen the blocks and attestations for the epoch
await sleep(this.clock.msToSlot(endSlotOfEpoch + 3 / 4));
const timer = this.metrics?.doppelganger.checkDuration.startTimer();
const timer = this.metrics?.doppelganger.checkDuration.startTimer({epoch: String(currentEpoch)});
const indices = await this.getIndicesToCheck(currentEpoch);
if (indices.length !== 0) {
const previousEpoch = currentEpoch - 1;
@@ -142,6 +142,7 @@ export class DoppelgangerService {
this.metrics?.doppelganger.status.set(
{
epoch: String(currentEpoch),
validatorIndex: String(validatorIndexToBeChecked.index),
},
doppelgangerStatusMetrics[this.getStatus(validatorIndexToBeChecked.index)]