From 3949234e07a78044c50aa3f7c6a983e11c73260e Mon Sep 17 00:00:00 2001 From: urvisavla Date: Fri, 27 Oct 2023 10:24:17 -0700 Subject: [PATCH] Add objectives in prometheus metrics because default objectives are deprecated in the updated version of prometheus go client. (#5092) --- ingest/ledgerbackend/metrics.go | 3 ++- services/horizon/internal/httpx/server.go | 3 ++- services/horizon/internal/ingest/main.go | 15 ++++++++++----- services/horizon/internal/txsub/system.go | 3 ++- support/db/metrics.go | 2 ++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ingest/ledgerbackend/metrics.go b/ingest/ledgerbackend/metrics.go index 2aae41f6cc..bebc42d733 100644 --- a/ingest/ledgerbackend/metrics.go +++ b/ingest/ledgerbackend/metrics.go @@ -17,7 +17,8 @@ func WithMetrics(base LedgerBackend, registry *prometheus.Registry, namespace st summary := prometheus.NewSummary( prometheus.SummaryOpts{ Namespace: namespace, Subsystem: "ingest", Name: "ledger_fetch_duration_seconds", - Help: "duration of fetching ledgers from ledger backend, sliding window = 10m", + Help: "duration of fetching ledgers from ledger backend, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, ) registry.MustRegister(summary) diff --git a/services/horizon/internal/httpx/server.go b/services/horizon/internal/httpx/server.go index 7fcaf379f2..65058c0ea5 100644 --- a/services/horizon/internal/httpx/server.go +++ b/services/horizon/internal/httpx/server.go @@ -66,7 +66,8 @@ func NewServer(serverConfig ServerConfig, routerConfig RouterConfig, ledgerState RequestDurationSummary: prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "http", Name: "requests_duration_seconds", - Help: "HTTP requests durations, sliding window = 10m", + Help: "HTTP requests durations, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, []string{"status", "route", "streaming", "method"}, ), diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index dbc586e8ff..6535a3e097 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -336,22 +336,26 @@ func (s *system) initMetrics() { s.metrics.LedgerIngestionDuration = prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_duration_seconds", - Help: "ledger ingestion durations, sliding window = 10m", + Help: "ledger ingestion durations, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) s.metrics.LedgerIngestionTradeAggregationDuration = prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_trade_aggregation_duration_seconds", - Help: "ledger ingestion trade aggregation rebuild durations, sliding window = 10m", + Help: "ledger ingestion trade aggregation rebuild durations, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) s.metrics.LedgerIngestionReapLookupTablesDuration = prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_reap_lookup_tables_duration_seconds", - Help: "ledger ingestion reap lookup tables durations, sliding window = 10m", + Help: "ledger ingestion reap lookup tables durations, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) s.metrics.StateVerifyDuration = prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "ingest", Name: "state_verify_duration_seconds", - Help: "state verification durations, sliding window = 10m", + Help: "state verification durations, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) s.metrics.StateInvalidGauge = prometheus.NewGaugeFunc( @@ -400,7 +404,8 @@ func (s *system) initMetrics() { s.metrics.ProcessorsRunDurationSummary = prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "ingest", Name: "processor_run_duration_seconds", - Help: "run durations of ingestion processors, sliding window = 10m", + Help: "run durations of ingestion processors, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, []string{"name"}, ) diff --git a/services/horizon/internal/txsub/system.go b/services/horizon/internal/txsub/system.go index 4dd492a9f8..189f1619ff 100644 --- a/services/horizon/internal/txsub/system.go +++ b/services/horizon/internal/txsub/system.go @@ -353,7 +353,8 @@ func (sys *System) Init() { sys.Metrics.SubmissionDuration = prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "horizon", Subsystem: "txsub", Name: "submission_duration_seconds", - Help: "submission durations to Stellar-Core, sliding window = 10m", + Help: "submission durations to Stellar-Core, sliding window = 10m", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) sys.Metrics.FailedSubmissionsCounter = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: "horizon", Subsystem: "txsub", Name: "failed", diff --git a/support/db/metrics.go b/support/db/metrics.go index f8b6fb9740..0726a85f91 100644 --- a/support/db/metrics.go +++ b/support/db/metrics.go @@ -82,6 +82,7 @@ func RegisterMetrics(base *Session, namespace string, sub Subservice, registry * Namespace: namespace, Subsystem: "db", Name: "query_duration_seconds", ConstLabels: prometheus.Labels{"subservice": string(sub)}, + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, []string{"query_type", "error", "route"}, ) @@ -232,6 +233,7 @@ func RegisterMetrics(base *Session, namespace string, sub Subservice, registry * Name: "round_trip_time_seconds", Help: "time required to run `select 1` query in a DB - effectively measures round trip time, if time exceeds 1s it will be recorded as 1", ConstLabels: prometheus.Labels{"subservice": string(sub)}, + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, ) registry.MustRegister(s.roundTripTimeSummary)