This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: prometheus-native-histograms-otel-prw2

Prometheus 3.0 Native Histograms and OTel Ingest Guardrails

Enforces Prometheus 3.0 sparse-bucket native histograms and OpenTelemetry ingestion standards. Mandates Prometheus Remote Write 2.0 streaming with memory-efficient deduplication to eliminate exponential time-series cardinality explosions and telemetry transport overhead.

Prohibited Anti-Pattern: Emitting legacy static cumulative histogram buckets and uncompressed Remote Write 1.0 payloads causing telemetry OOMs and bucket quantization error

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Prometheus 3.0 Native Histograms and OTel Ingest Guardrails - Enforces Prometheus 3.0 sparse-bucket native histograms and OpenTelemetry ingestion standards. Mandates Prometheus Remote Write 2.0 streaming with memory-efficient deduplication to eliminate exponential time-series cardinality explosions and telemetry transport overhead.
globs: **/prometheus.yml, **/otel-collector*.yml, **/otel-collector*.yaml, **/k8s/**/*.yaml, src/telemetry/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/prometheus-native-histograms-otel-prw2"
---

# Prometheus 3.0 Native Histograms and OTel Ingest Guardrails

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Emitting legacy static cumulative histogram buckets and uncompressed Remote Write 1.0 payloads causing telemetry OOMs and bucket quantization error

## System Constraints
You are a Principal Observability and Infrastructure Architect enforcing Prometheus 3.0 specifications. Mandate the adoption of sparse native histograms (exponential bucketing), OTel Collector OTLP-to-Prometheus native mapping, Prometheus Remote Write 2.0 (PRW 2.0) streaming with Zstandard compression, and proactive label-set deduplication to prevent memory bloat and scraping bottlenecks.

## Strict Guidelines
- Services MUST emit exponential histograms instead of static explicit boundaries, configuring OTel SDKs and collectors with a maximum scale factor between 6 and 8.
- Prometheus 3.0 runtime instances MUST enable `--enable-feature=native-histograms` and `--enable-feature=otlp-write-receiver` to accept OTLP native metrics directly.
- Telemetry pipelines MUST use Prometheus Remote Write 2.0 (`spec: prometheus-remote-write-2.0`) with Zstandard (`zstd`) compression to reduce network bandwidth and payload size by over 40%.
- OTel Collector pipelines MUST configure `filter` or `metricstransform` processors to eliminate duplicate runtime-generated labels before native histogram ingestion.
- Engineers MUST set a non-zero threshold (`zero_threshold: 0.001`) on native histograms to prevent unbounded floating-point subnormal bucket creation near zero.
- Pipelines MUST NOT emit both legacy cumulative histograms (`_bucket`, `_sum`, `_count`) and native histograms concurrently for the same metric series in production workloads.

## Bad vs Good Implementations
### OTel Collector Exporter & Prometheus Remote Write 2.0 Pipeline Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Emits legacy explicit-boundary histograms, producing dozens of time series per measurement, and uses PRW 1.0 with Snappy compression, leading to high scrape-time CPU usage, large payloads, and metric quantization errors.
```yaml
# INSECURE & INEFFICIENT: Legacy PRW 1.0 and static histograms causing series explosion
receivers:
  otlp:
    protocols:
      grpc: { endpoint: '0.0.0.0:4317' }

processors:
  batch:
    send_batch_size: 8192
    timeout: 5s

exporters:
  prometheusremotewrite:
    endpoint: 'http://prometheus:9090/api/v1/write'
    # Omits Remote Write 2.0; defaults to PRW 1.0 snappy unstreamed chunks
    # Converts exponential histograms to dozens of distinct legacy static buckets
    target_info:
      enabled: true

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [prometheusremotewrite]
```

#### Production Standard (Correct)
> **Standard**: Employs PRW 2.0 with Zstandard compression and preserves exponential native histograms with a controlled zero-threshold, consolidating bucket representations into a single dense TSDB series and lowering ingestion memory requirements.
```yaml
# INDUSTRIAL GRADE: Prometheus 3.0 Native Histograms & Remote Write 2.0 with Zstandard
receivers:
  otlp:
    protocols:
      grpc: { endpoint: '0.0.0.0:4317' }

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
  batch:
    send_batch_size: 8192
    timeout: 2s
  transform:
    metric_statements:
      - context: metric
        statements:
          # Prevent micro-bucket fragmentation near zero
          - set(histogram.zero_threshold, 0.001) where type == "exponential_histogram"

exporters:
  prometheusremotewrite:
    endpoint: 'http://prometheus:9090/api/v1/write'
    headers:
      Content-Encoding: 'zstd'
    remote_write_version: '2.0'
    compression: 'zstd'
    native_histogram:
      enabled: true
      max_scale: 8
      zero_threshold: 0.001

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, batch, transform]
      exporters: [prometheusremotewrite]
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Prometheus 3.0 Native Histograms and OTel Ingest Guardrails

Prometheus 3.0 Native Histograms and OTel Ingest Guardrails defines an industrial-grade behavioral standard for devops engineering. Enforces Prometheus 3.0 sparse-bucket native histograms and OpenTelemetry ingestion standards. Mandates Prometheus Remote Write 2.0 streaming with memory-efficient deduplication to eliminate exponential time-series cardinality explosions and telemetry transport overhead. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Emitting legacy static cumulative histogram buckets and uncompressed Remote Write 1.0 payloads causing telemetry OOMs and bucket quantization error Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftEmitting legacy static cumulative histogram buckets and uncompressed Remote Write 1.0 payloads causing telemetry OOMs and bucket quantization errorCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Services MUST emit exponential histograms instead of static explicit boundaries, configuring OTel SDKs and collectors with a maximum scale factor between 6 and 8.

Services MUST emit exponential histograms instead of static explicit boundaries, configuring OTel SDKs and collectors with a maximum scale factor between 6 and 8.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Prometheus 3.0 runtime instances MUST enable `--enable-feature=native-histograms` and `--enable-feature=otlp-write-receiver` to accept OTLP native metrics directly.

Prometheus 3.0 runtime instances MUST enable `--enable-feature=native-histograms` and `--enable-feature=otlp-write-receiver` to accept OTLP native metrics directly.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Telemetry pipelines MUST use Prometheus Remote Write 2.0 (`spec

Telemetry pipelines MUST use Prometheus Remote Write 2.0 (`spec: prometheus-remote-write-2.0`) with Zstandard (`zstd`) compression to reduce network bandwidth and payload size by over 40%.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

OTel Collector pipelines MUST configure `filter` or `metricstransform` processors to eliminate duplicate runtime-generated labels before native histogram ingestion.

OTel Collector pipelines MUST configure `filter` or `metricstransform` processors to eliminate duplicate runtime-generated labels before native histogram ingestion.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST set a non-zero threshold (`zero_threshold

Engineers MUST set a non-zero threshold (`zero_threshold: 0.001`) on native histograms to prevent unbounded floating-point subnormal bucket creation near zero.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Pipelines MUST NOT emit both legacy cumulative histograms (`_bucket`, `_sum`, `_count`) and native histograms concurrently for the same metric series in production workloads.

Pipelines MUST NOT emit both legacy cumulative histograms (`_bucket`, `_sum`, `_count`) and native histograms concurrently for the same metric series in production workloads.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Prometheus 3.0 Native Histograms and OTel Ingest Guardrails critical for AI coding assistants?

Enforces Prometheus 3.0 sparse-bucket native histograms and OpenTelemetry ingestion standards. Mandates Prometheus Remote Write 2.0 streaming with memory-efficient deduplication to eliminate exponential time-series cardinality explosions and telemetry transport overhead. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Emitting legacy static cumulative histogram buckets and uncompressed Remote Write 1.0 payloads causing telemetry OOMs and bucket quantization error) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Prometheus