Skip to content
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

blob size metric #118

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jobs:
with:
version: v1.60
args: --timeout 3m

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ An optional storage caching CLI flag `--routing.cache-targets` can be leveraged

To the see list of available metrics, run `./bin/eigenda-proxy doc metrics`

To quickly set up monitoring dashboard, add eigenda-proxy metrics endpoint to a reachable prometheus server config as a scrape target, add prometheus datasource to Grafana to, and import the existing [Grafana dashboard JSON file](./grafana_dashboard.json)

## Deployment Guide

### Hardware Requirements
Expand Down
6 changes: 6 additions & 0 deletions commitments/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"fmt"
)

type CommitmentMeta struct {
Mode CommitmentMode
// CertVersion is shared for all modes and denotes version of the EigenDA certificate
CertVersion string
}

type CommitmentMode string

const (
Expand Down
57 changes: 57 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
eigenda_proxy:
build:
context: .
dockerfile: Dockerfile
container_name: eigenda-proxy
environment:
- EIGENDA_PROXY_ADDR=0.0.0.0
- EIGENDA_PROXY_PORT=4242
- MEMSTORE_ENABLED=false
- MEMSTORE_EXPIRATION=45m
- EIGENDA_PROXY_SIGNER_PRIVATE_KEY_HEX=$PRIVATE_KEY
- EIGENDA_PROXY_EIGENDA_DISPERSER_RPC=disperser-holesky.eigenda.xyz:443
- EIGENDA_PROXY_SERVICE_MANAGER_ADDR=0xD4A7E1Bd8015057293f0D0A557088c286942e84b
- EIGENDA_PROXY_ETH_RPC=$ETH_RPC
- EIGENDA_PROXY_ETH_CONFIRMATION_DEPTH=0
- EIGENDA_PROXY_METRICS_ADDR=0.0.0.0
- EIGENDA_PROXY_METRICS_ENABLED=true
- EIGENDA_PROXY_METRICS_PORT=7300
ports:
- 4242:4242
- 7300:7300

prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./monitor/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
command:
- "--config.file=/etc/prometheus/prometheus.yml"

grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "127.0.0.1:3000:3000"
volumes:
- ./monitor/grafana/provisioning/:/etc/grafana/provisioning/:ro
- ./monitor/grafana/dashboards:/var/lib/grafana/dashboards
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
depends_on:
- prometheus

traffic-generator:
image: alpine:latest
build: scripts/
container_name: traffic_generator
depends_on:
- eigenda_proxy
volumes:
- ./scripts/:/scripts/

volumes:
grafana-data:
45 changes: 37 additions & 8 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type Config struct {
type Metricer interface {
RecordInfo(version string)
RecordUp()
RecordRPCServerRequest(method string) func(status string)
RecordRPCServerRequest(method string) func(status string, commitmentMode string, version string)
RecordBlobSize(method string, mode string, ver string, size int)

Document() []metrics.DocumentedMetric
}
Expand All @@ -40,7 +41,9 @@ type Metrics struct {
Up prometheus.Gauge

HTTPServerRequestsTotal *prometheus.CounterVec
HTTPServerBadRequestHeader *prometheus.CounterVec
HTTPServerRequestDurationSeconds *prometheus.HistogramVec
BlobSizeBytes *prometheus.HistogramVec

registry *prometheus.Registry
factory metrics.Factory
Expand Down Expand Up @@ -79,7 +82,15 @@ func NewMetrics(subsystem string) *Metrics {
Name: "requests_total",
Help: "Total requests to the HTTP server",
}, []string{
"method", "status",
"method", "status", "commitment_mode", "commitment_version",
}),
HTTPServerBadRequestHeader: factory.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: httpServerSubsystem,
Name: "requests_bad_header_total",
Help: "Total requests to the HTTP server with bad headers",
}, []string{
"method", "error_type",
}),
HTTPServerRequestDurationSeconds: factory.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Expand All @@ -90,7 +101,17 @@ func NewMetrics(subsystem string) *Metrics {
Buckets: prometheus.ExponentialBucketsRange(0.05, 1200, 20),
Help: "Histogram of HTTP server request durations",
}, []string{
"method", // no status on histograms because those are very expensive
"method", "commitment_mode", "commitment_version", // no status on histograms because those are very expensive
}),
BlobSizeBytes: factory.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "blob_size_bytes",
Help: "Histogram of blob size in bytes",
Buckets: prometheus.ExponentialBucketsRange(1, 1000000000, 20),
}, []string{
//Todo: add store as a label
"method", "commitment_mode", "certificate_version",
}),
registry: registry,
factory: factory,
Expand All @@ -112,16 +133,21 @@ func (m *Metrics) RecordUp() {
// RecordRPCServerRequest is a helper method to record an incoming HTTP request.
// It bumps the requests metric, and tracks how long it takes to serve a response,
// including the HTTP status code.
func (m *Metrics) RecordRPCServerRequest(method string) func(status string) {
func (m *Metrics) RecordRPCServerRequest(method string) func(status string, mode string, ver string) {
// we don't want to track the status code on the histogram because that would
// create a huge number of labels, and cost a lot on cloud hosted services
timer := prometheus.NewTimer(m.HTTPServerRequestDurationSeconds.WithLabelValues(method))
return func(status string) {
m.HTTPServerRequestsTotal.WithLabelValues(method, status).Inc()
return func(status, mode, ver string) {
m.HTTPServerRequestsTotal.WithLabelValues(method, status, mode, ver).Inc()
timer.ObserveDuration()
}
}

// RecordBlobSize records the size of a blob in bytes
func (m *Metrics) RecordBlobSize(method string, mode string, ver string, size int) {
m.BlobSizeBytes.WithLabelValues(method, mode, ver).Observe(float64(size))
}

// StartServer starts the metrics server on the given hostname and port.
func (m *Metrics) StartServer(hostname string, port int) (*ophttp.HTTPServer, error) {
addr := net.JoinHostPort(hostname, strconv.Itoa(port))
Expand Down Expand Up @@ -150,6 +176,9 @@ func (n *noopMetricer) RecordInfo(_ string) {
func (n *noopMetricer) RecordUp() {
}

func (n *noopMetricer) RecordRPCServerRequest(string) func(status string) {
return func(string) {}
func (n *noopMetricer) RecordRPCServerRequest(string) func(status, mode, ver string) {
return func(string, string, string) {}
}

func (n *noopMetricer) RecordBlobSize(string, string, string, int) {
}
Loading
Loading