redmetrics

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

RED Metrics Examples

This directory contains OpenSLO examples for RED (Rate, Errors, Duration) metrics, a service-level monitoring methodology focused on request-driven services.

What are RED Metrics?

RED is a monitoring framework introduced by Tom Wilkie at Grafana Labs, designed specifically for monitoring request-driven services (APIs, microservices, web applications). The three pillars are:

  • Rate: The number of requests per second your service is handling
  • Errors: The number/percentage of those requests that are failing
  • Duration: The amount of time those requests take (typically measured as latency percentiles)

Files in this Directory

rate.go

Measures the request rate (throughput) for an API service:

  • ExampleRateSLO - Tracks requests per second to ensure the service handles expected traffic volume
error.go

Monitors the error rate of requests:

  • ExampleErrorRateSLO - Tracks the ratio of successful responses (2xx, 3xx) vs errors (4xx, 5xx)
duration.go

Tracks request latency and response times:

  • ExampleDurationSLO - Measures P95 latency to ensure fast response times
  • ExampleDurationP99SLO - Measures P99 latency for tail latency monitoring
red_test.go

Validation tests for all RED metric SLOs

When to Use RED Metrics

RED metrics are ideal for:

  • Request-driven services: REST APIs, GraphQL APIs, microservices
  • Web applications: Backend services handling HTTP requests
  • Service-to-service communication: Internal API calls
  • User-facing endpoints: Any service where users make requests

Example Prometheus Queries

The examples use Prometheus as the metric source with queries like:

Rate:

rate(http_requests_total[5m])

Errors:

sum(rate(http_requests_total{status=~"2..|3.."}[5m])) / sum(rate(http_requests_total[5m]))

Duration:

histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))

Complementary Frameworks

  • USE Metrics: For infrastructure/resource monitoring (see ../use-metrics/)
  • Four Golden Signals: Google's framework (similar to RED + Saturation)
  • DORA Metrics: For measuring DevOps/deployment performance

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleAvailabilitySLO

func ExampleAvailabilitySLO() v1.SLO

ExampleAvailabilitySLO is a derived SLO that measures service availability. Availability is calculated from Rate (R) and Error (E) metrics in RED - combining whether the service is handling requests AND those requests are successful.

func ExampleDurationP99SLO

func ExampleDurationP99SLO() v1.SLO

ExampleDurationP99SLO is a SLO that measures P99 latency for more stringent requirements.

func ExampleDurationSLO

func ExampleDurationSLO() v1.SLO

ExampleDurationSLO is a SLO that measures request duration (latency). Duration is the "D" in RED metrics - tracking how long requests take to complete.

func ExampleErrorRateSLO

func ExampleErrorRateSLO() v1.SLO

ExampleErrorRateSLO is a SLO that measures the error rate of requests. Error rate is the "E" in RED metrics - tracking the proportion of failed requests.

func ExampleRateSLO

func ExampleRateSLO() v1.SLO

ExampleRateSLO is a SLO that measures the request rate (requests per second) for an API service. Rate is the "R" in RED metrics - tracking how many requests the service handles.

func SLOs

func SLOs() []v1.SLO

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL