Implement Memory Limiter prototype - #2
Closed
dashpole wants to merge 72 commits into
Closed
Conversation
dashpole
force-pushed
the
memory_limiter_prototype
branch
from
August 8, 2026 02:15
30588f1 to
53c1496
Compare
dashpole
pushed a commit
that referenced
this pull request
Aug 8, 2026
* Initial plan * Add Azure AD certificate-based authentication support Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> * Update documentation for certificate-based authentication Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> * Address code review feedback - improve error messages and format detection Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> * Replace third-party go-pkcs12 with official golang.org/x/crypto/pkcs12 Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> * Extract certificate parsing to common util/certutil package Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> * Fix linting errors: import ordering and comment formatting Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bragi92 <28612268+bragi92@users.noreply.github.com>
dashpole
force-pushed
the
memory_limiter_prototype
branch
from
August 13, 2026 19:12
9b499bf to
95978b4
Compare
…l fields
Lightsail SD guarded only PrivateIpAddress before building the label set, then
dereferenced six more pointers unconditionally:
lightsailLabelAZ: model.LabelValue(*inst.Location.AvailabilityZone),
lightsailLabelBlueprintID: model.LabelValue(*inst.BlueprintId),
lightsailLabelBundleID: model.LabelValue(*inst.BundleId),
lightsailLabelInstanceName: model.LabelValue(*inst.Name),
lightsailLabelInstanceState: model.LabelValue(*inst.State.Name),
lightsailLabelInstanceSupportCode: model.LabelValue(*inst.SupportCode),
Every one of those is optional in the AWS API. Location is a *ResourceLocation
and State an *InstanceState, so those two chain through a second pointer each.
If the API omits any of them the refresh goroutine panics with a nil pointer
dereference and takes the whole Prometheus process down, rather than degrading
the single target.
Each label is now emitted only when its source field is present, matching the
guarding already used throughout elasticache.go. An instance that carries
nothing but a private IP still produces a scrapeable target.
Adds discovery/aws/lightsail_test.go; the package had no Lightsail coverage,
which is why this went unnoticed. Without the fix
TestLightsailRefreshAllOptionalFieldsNil panics at lightsail.go:262.
Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
Serverless MSK clusters have no Provisioned configuration, and provisioned clusters without Open Monitoring have a nil OpenMonitoring field. The refresh label building dereferences both without checking, crashing Prometheus. Exposes prometheus#19184 Signed-off-by: Raj <rajeshrajendirandev@gmail.com>
Serverless MSK clusters return a nil Provisioned field and provisioned clusters without Open Monitoring return a nil OpenMonitoring field. The refresh label building dereferenced both unconditionally, crashing the whole Prometheus process during service discovery. Guard the dereferences and omit the affected labels when the configuration is absent. Fixes prometheus#19184 Signed-off-by: Raj <rajeshrajendirandev@gmail.com>
Serverless clusters do not expose broker nodes and are already excluded from ListClustersV2 by the PROVISIONED filter, so an explicitly configured serverless cluster ARN is now skipped with a warning instead of being processed. Also document that the JMX and node exporter labels are absent, not false, when Open Monitoring is not enabled. Suggested by @matt-gp in the PR review. Signed-off-by: Raj <rajeshrajendirandev@gmail.com>
Since describeClusters and listClusters both only return provisioned clusters now, Provisioned and CurrentBrokerSoftwareInfo are always set; only Open Monitoring remains optional. Suggested by @matt-gp in review. Signed-off-by: Raj <rajeshrajendirandev@gmail.com>
…9359) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…theus#19350) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…theus#19357) * fix(deps): update module github.com/moby/moby/client to v0.5.1 * build: bump minimum Go version to 1.25.10 --------- Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
… c8921c7 (prometheus#19244) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…rometheus#19109) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This fixes scroll issues in the native histogram buckets table and also improves the display by aligning the values better and adding a light background bar representing the bucket count. Signed-off-by: Julius Volz <julius.volz@gmail.com>
…ometheus#19356) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…0-beta.37 (prometheus#19358) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#19362) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* promql: honour @ modifier when evaluating info() series --------- Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com> Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
* chore(deps): update modules --------- Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix(deps): update dependency react-router-dom to v7 * ui: migrate legacy app to React Router v7 --------- Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
* chore(deps): update mantine ui * chore(deps): keep eslint plugin at v0.5.3 Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> --------- Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
…s#18883) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: linasm <linas.medziunas@gmail.com>
…ing (prometheus#19401) * tsdb: document that OOO chunk IDs are no longer monotonically increasing Follow-up to prometheus#19216: the HeadChunkID doc still promised a monotonically increasing per-series number, which no longer holds for out-of-order chunk IDs now that they wrap modulo 2^23. Also spell out the "much less than" relation in the oooHeadChunkID comment, where << is easy to misread as a bit-shift. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update tsdb/head_read.go Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
…yLimiterConfig.Validate
…lockCompaction until TSDB integration is implemented
…ory limit rejection
dashpole
force-pushed
the
memory_limiter_prototype
branch
from
August 13, 2026 19:31
95978b4 to
33955d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prometheus Memory Limiter: Implementation Plan & Design Document
This document defines the architectural specification, component design, integration points, and rollout for the Prometheus Memory Limiter (prometheus/proposals#76).
1. System Architecture Overview
The Memory Limiter acts as a centralized runtime circuit breaker. It periodically evaluates memory pressure using Go's runtime metrics (
runtime/metrics) and coordinates load-shedding mitigations across Prometheus subsystems without modifying Go runtime tuning parameters (GOMEMLIMIT/GOGCare treated strictly as read-only inputs).2. Core Controller Engine (
pkg/memorylimiter)2.1 Package Interface and Data Types
2.2 Memory Pressure Sensor & GC Pacer Accounting
The limiter queries
runtime/metricson a background ticker (default 100ms) with zero allocations.Sensor Derivation:
/gc/gomemlimit:bytesreturnsmath.MaxInt64(unconfigured) when--enable-feature=memory-limiteris set, Prometheus fails fast at startup with an explicit error:memory limiter requires GOMEMLIMIT or --auto-gomemlimit to be configured./gc/limiter/last-enabled:gc-cycleadvanced in the last evaluation window, Go's GC CPU limiter has engaged (meaning Go is spending >50% CPU in GC trying to stay under GOMEMLIMIT). In this state, the memory limiter immediately escalates toStateHardLimit, regardless of whetherin_use / GOMEMLIMIThas crossedhard_limit_ratio.2.3 State Transitions & Flapping Observability
As specified in the proposal, state transitions are evaluated directly against the configured ratios:
in_use / GOMEMLIMIT >= soft_limit_ratio(default0.70).in_use / GOMEMLIMIT >= hard_limit_ratio(default0.85) ORgc_limiter_active.prometheus_memory_limiter_transitions_total{from, to}and records time inprometheus_memory_limiter_engaged_seconds_total{limit}. This enables direct measurement of transition frequency and duty cycles to evaluate the impact of flapping under sustained boundary load.3. Subsystem Integrations & Mitigations
3.1 Scrape Loop (
scrape/scrape.go)When
AllowScrape()isfalse:errScrapeMemoryLimitExceeded.up=0or staleness markers to the WAL. The transaction is bypassed, ensuringprometheus_target_scrapes_skipped_total{job, instance}.3.2 TSDB Compaction (
tsdb/db.go,tsdb/compact.go)Mitigation level: Soft Limit.
DB.compactBlocks()(on-disk block merging). Pausing block compaction carries zero risk of data loss and does not affect ingestion capacity.DB.CompactHead()and WAL truncation MUST continue running. Active Head memory and WAL disk size remain bounded.blockCompactionPausedchecked before acquiring the block compaction lock intsdb.DB.run().3.3 HTTP Handlers (
web/api/v1/api.go,web/web.go,otlp/receiver.go)When respective limiters are active:
/api/v1/otlp) & Remote Write Receiver (/api/v1/write):503 Service Unavailablewith headerRetry-After: 5./api/v1/read) & Federation (/federate):503 Service UnavailablewithRetry-After: 5.3.4 Rules Engine (
rules/manager.go)Mitigation level: Hard Limit.
prometheus_rule_group_iterations_skipped_total{rule_group}.4. Configuration Schema (
config/config.go)5. Exported Telemetry Specification
prometheus_memory_limiter_activelimit="soft|hard"prometheus_memory_limiter_engaged_seconds_totallimit="soft|hard"prometheus_memory_limiter_transitions_totalfrom, toprometheus_memory_limiter_limit_byteslimit="soft|hard"prometheus_memory_limiter_in_use_bytestotal - released).prometheus_target_scrapes_skipped_totaljob, instanceprometheus_tsdb_block_compaction_pausedprometheus_rule_group_iterations_skipped_totalrule_group