-
Notifications
You must be signed in to change notification settings - Fork 268
Prometheus Metrics #832
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
Prometheus Metrics #832
Changes from all commits
92b6aa4
f3a9e17
5b8b817
42a06e7
c6096a4
7b272c5
3da1776
14c071b
c494d4a
e7beab8
146779a
1769b72
1f8ac47
75ef195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ const ( | |||||||||||||||
GenesisCategory = "GENESIS" | ||||||||||||||||
RelayCategory = "RELAYS" | ||||||||||||||||
GeneralCategory = "GENERAL" | ||||||||||||||||
Metrics = "METRICS" | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
var flags = []cli.Flag{ | ||||||||||||||||
|
@@ -35,6 +36,10 @@ var flags = []cli.Flag{ | |||||||||||||||
timeoutGetPayloadFlag, | ||||||||||||||||
timeoutRegValFlag, | ||||||||||||||||
maxRetriesFlag, | ||||||||||||||||
|
||||||||||||||||
// metrics | ||||||||||||||||
metricsFlag, | ||||||||||||||||
metricsAddrFlag, | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
var ( | ||||||||||||||||
|
@@ -178,4 +183,19 @@ var ( | |||||||||||||||
Value: 5, | ||||||||||||||||
Category: RelayCategory, | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// metrics | ||||||||||||||||
metricsFlag = &cli.BoolFlag{ | ||||||||||||||||
Name: "metrics", | ||||||||||||||||
Sources: cli.EnvVars("METRICS_ENABLED"), | ||||||||||||||||
Usage: "enables a metrics server", | ||||||||||||||||
Category: Metrics, | ||||||||||||||||
} | ||||||||||||||||
metricsAddrFlag = &cli.StringFlag{ | ||||||||||||||||
Name: "metrics-addr", | ||||||||||||||||
Sources: cli.EnvVars("METRICS_ADDR"), | ||||||||||||||||
Value: "localhost:18551", | ||||||||||||||||
Usage: "listening address for the metrics server", | ||||||||||||||||
Category: Metrics, | ||||||||||||||||
} | ||||||||||||||||
Comment on lines
+194
to
+200
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. minor nit: it would be nice to separate it out to metrics-addr and metrics-port into separate flags. 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. This actually mirrors how we do it elsewhere. I'd like to keep it like this for consistency. Lines 42 to 48 in 7e47dd2
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. alright sounds good |
||||||||||||||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package server | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/VictoriaMetrics/metrics" | ||
) | ||
|
||
var winningBidValue = metrics.NewHistogram("mev_boost_winning_bid_value") | ||
|
||
const ( | ||
beaconNodeStatusLabel = `mev_boost_beacon_node_status_code_total{http_status_code="%s",endpoint="%s"}` | ||
bidValuesLabel = `mev_boost_bid_values{relay="%s"}` | ||
bidsBelowMinBidLabel = `mev_boost_bids_below_min_bid_total{relay="%s"}` | ||
relayLatencyLabel = `mev_boost_relay_latency{endpoint="%s",relay="%s"}` | ||
relayStatusCodeLabel = `mev_boost_relay_status_code_total{http_status_code="%s",endpoint="%s",relay="%s"}` | ||
relayLastSlotLabel = `mev_boost_relay_last_slot{relay="%s"}` | ||
msIntoSlotLabel = `mev_boost_millisec_into_slot{endpoint="%s"}` | ||
) | ||
|
||
func IncrementBeaconNodeStatus(status, endpoint string) { | ||
l := fmt.Sprintf(beaconNodeStatusLabel, status, endpoint) | ||
metrics.GetOrCreateCounter(l).Inc() | ||
} | ||
|
||
func RecordBidValue(relay string, value float64) { | ||
l := fmt.Sprintf(bidValuesLabel, relay) | ||
metrics.GetOrCreateHistogram(l).Update(value) | ||
} | ||
|
||
func IncrementBidBelowMinBid(relay string) { | ||
l := fmt.Sprintf(bidsBelowMinBidLabel, relay) | ||
metrics.GetOrCreateCounter(l).Inc() | ||
} | ||
|
||
func RecordWinningBidValue(value float64) { | ||
winningBidValue.Update(value) | ||
} | ||
|
||
func RecordRelayLatency(endpoint, relay string, latency float64) { | ||
l := fmt.Sprintf(relayLatencyLabel, endpoint, relay) | ||
metrics.GetOrCreateHistogram(l).Update(latency) | ||
} | ||
|
||
func RecordRelayStatusCode(httpStatus, endpoint, relay string) { | ||
l := fmt.Sprintf(relayStatusCodeLabel, httpStatus, endpoint, relay) | ||
metrics.GetOrCreateCounter(l).Inc() | ||
} | ||
|
||
func RecordRelayLastSlot(relay string, slot uint64) { | ||
l := fmt.Sprintf(relayLastSlotLabel, relay) | ||
metrics.GetOrCreateGauge(l, nil).Set(float64(slot)) | ||
} | ||
|
||
func RecordMsIntoSlot(endpoint string, ms float64) { | ||
l := fmt.Sprintf(msIntoSlotLabel, endpoint) | ||
metrics.GetOrCreateHistogram(l).Update(ms) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are both flags necessary, or should we only use
-metrics-addr
and when set then enable, and by default empty string disable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this would require the user provide a URL/port. Not quite as simple as "enable with
-metrics
".I think we did it this way because it mimics how clients do it, eg: