Prometheus
prometheus.io › docs › prometheus › latest › configuration › recording_rules
Defining recording rules | Prometheus
If there are any syntax errors or invalid input arguments, it prints an error message to standard error and exits with a 1 return status. Recording rules allow you to precompute frequently needed or computationally expensive expressions and save their result as a new set of time series.
Prometheus
prometheus.io › docs › practices › rules
Recording rules | Prometheus
- record: job:request_latency_seconds_count:avg_rate5m expr: avg without (instance, path)(instance_path:request_latency_seconds_count:rate5m{job="myjob"}) Notice that when aggregating that the labels in the without clause are removed from the level of the output metric name compared to the input metric names. When there is no aggregation, the levels always match. If this is not the case a mistake has likely been made in the rules.
Recording Rules in Prometheus
Recording rules run the query you specify on a timer, and write the output of that query to the TSDB. So if you configure a rule like this: - record: job:up:avg expr: avg without (instance) (up) It will take metrics like this: up{job="node",instance="foo:9100"} 1.0 up{job="node",instance="bar:9100"} 1.0 up{job="web",instance="foo:8080"} 1.0 up{job="web",instance="bar:8080"} 0.0 And store this in the TSDB: job:up:avg{job="node"} 1.0 job:up:avg{job="web"} 0.5 It will run this at whatever interval you specify in the rule group. More on reddit.com
How to change default servicemonitors interval in monitoring operator
Modify Prometheus Configuration: Instead of modifying the ServiceMonitor directly, you should change the Prometheus configuration. This can be done by editing the Prometheus custom resource in the openshift-monitoring namespace. Adjust the scrape_interval setting to a higher value to reduce the frequency of scrapes. Use Retention and Storage Settings: Adjust the data retention period and storage size in the Prometheus configuration. This can help manage the resource consumption.Scale Up Prometheus Instances: Consider scaling up the number of Prometheus instances to distribute the load. Optimize or Reduce Targets: Analyze if all targets are necessary or if some metrics can be dropped. This reduces the amount of data Prometheus needs to scrape and store. Monitor and Adjust Resource Allocation: Continuously monitor the resource utilization of Prometheus and adjust CPU and memory requests and limits accordingly. Implement Thanos or Remote Storage: For long-term storage and efficient querying, consider integrating Thanos or another remote storage solution. More on reddit.com
relabel and aggregate metrics
For future travelers here is what I found after looking around.Prometheus cant do what I'm asking for directly since running the sum (aggergation) query requires the data to be in the tsdb , which deafets the purpose of doing the aggregation on scrap. There are other ways to do this. writing your own exporter; basically hack a python script and expose /metrics that scrap rabbitmq and do the aggregation on demand without having a state. having another prometheus instance with a recording rule federated to the main instance, this will be the most compatible but will cause delays of queries since recording rules gets evaluated after the scrap getting stored using victoriametrics aggregation via a cheap single instance server with the lowest retention possible then using the /federate endpoint as a scrap endpoint for my main prometheus give up and just dont collect those metrics I choose the 3rd option since it is the most sane one. Although I dont like having this victoriametrics instance just to aggregate, and I dont want to maintain or solve the problems related to metrics aggregation with my own hacky python script, I have no other choice but to use this. If anyone else have a better solution let me know edit: note with victoriametrics, the only shared metrics with the federate endpoint are the aggregated ones, so you might need to scrap twice, once for prometheus with dropping the labels you want to aggregate, and second for victoriametrics with the labels you want to aggregate More on reddit.com
Help!! KSM (kube-state- metrics) partially scraped while using Prometheus/Thanos Sharding
Today faced same issue :(( More on reddit.com
24:42
06 How to configure recording & Alerting Rules with example in ...
14:23
Recording Rules in Prometheus | Prometheus Recording Rules | ...
06:48
Prometheus Tutorial | Prometheus Recorded Rule - YouTube
12:47
Introduction to Recording Rules - Use Case: Grafana Loki Metric ...
02:02
Prometheus recording rules - YouTube
Promlabs
training.promlabs.com › training › recording-rules › recording-rules-overview › configuring-recording-rules
Recording Rules | Prometheus Trainings by PromLabs
You can define recording rules in so-called rule files. Rule files are YAML-based configuration files that are separate from the main Prometheus configuration file. Each rule file contains a list of rule groups (top-level groups field), and each group may in turn contain both recording rules ...
Last9
last9.io › blog › prometheus-recording-rules
Prometheus Recording Rules: A Developer's Guide | Last9
February 26, 2026 - Creating Custom Metrics: Sometimes, you need metrics that don’t exist out of the box. Recording Rules allow you to define these custom metrics based on existing data. ... Check out our practical guide on using the Prometheus Rate function to learn how it works and how to apply it effectively.
Reddit
reddit.com › r/kubernetes › recording rules in prometheus
r/kubernetes on Reddit: Recording Rules in Prometheus
May 4, 2021 -
I understand that recording rules are used by Prometheus to precompute expensive queries which are needed frequently but still I am not getting clear with what exactly is recording rules are and how they are working?
AWS
docs.aws.amazon.com › amazon managed service for prometheus › user guide › using rules to modify or monitor metrics as they are received
Using rules to modify or monitor metrics as they are received - Amazon Managed Service for Prometheus
Amazon Managed Service for Prometheus supports two types of rules that it evaluates at regular intervals: Recording rules allow you to precompute frequently needed or computationally expensive expressions and save their results as a new set of time series.
AWS
docs.aws.amazon.com › amazon managed service for prometheus › user guide › using rules to modify or monitor metrics as they are received › create a rules file
Create a rules file - Amazon Managed Service for Prometheus
To use rules in Amazon Managed Service for Prometheus, you create a rules file that defines the rules. An Amazon Managed Service for Prometheus rules file is a YAML text file that has the same format as a rules file in standalone Prometheus. For more information, see Defining Recording rules
Google Groups
groups.google.com › g › prometheus-users › c › ZHhtXXEQ4Qg
Recording rules with OFFSET
to Prometheus Users · Hi, What are the best practices for rules with OFFSET? Example: --- groups: - name: example · rules: - record: job:http_inprogress_requests:sum · expr: sum(http_inprogress_requests) by (job) - record: job:http_inprogress_requests:sum ·
Spring
docs.spring.io › spring-boot › index.html
Spring Boot :: Spring Boot
Spring Boot helps you to create stand-alone, production-grade Spring-based applications that you can run. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration ...
Chronosphere
chronosphere.io › home › are prometheus recording rules the right tool for the job?
Using Prometheus Recording Rules to Your Advantage | Chronosphere
March 19, 2025 - Rules are structured into named groups, with each group having the ability to set the evaluation interval (default is 60s, as specified by the evaluation_interval option in the Prometheus configuration file), and an optional limit on the number of series that can be generated by the rules in the group. As part of the Prometheus server’s regular operation, it evaluates the provided rules on a schedule according to the configured evaluation interval for each group. Here’s an example recording rule group, to help illustrate:
Dmitri Lerko
deploy.live › blog › today-i-learned-prometheus-recording-rules
Today I Learned: Prometheus Recording Rules // Dmitri Lerko
July 14, 2019 - The essential idea of the recording rules is that it allows you to create custom, meta-time series based on other time series. If you are a Prometheus Operator user - you might have a large number of such rules running in your Prometheus already.
Reddit
reddit.com › r/prometheusmonitoring › prometheus backfilling: recording rules and alerts
r/PrometheusMonitoring on Reddit: Prometheus Backfilling: Recording Rules and Alerts
February 23, 2021 - For many Prometheus users using recording rules and alerts, a known issue is how both are only generated on the fly at runtime. This limitation has two downsides. First of all, any new recording rule will not be applied to your historical data.
OneUptime
oneuptime.com › home › blog › how to build prometheus recording rule optimization
How to Build Prometheus Recording Rule Optimization
January 30, 2026 - Here is a comprehensive recording rules configuration for a typical microservices environment: # /etc/prometheus/rules/recording_rules/microservices.yml groups: # Request rate and throughput metrics - name: request_metrics interval: 30s rules: - record: service:http_requests_total:rate5m expr: sum by (service, method, status_code) (rate(http_requests_total[5m])) - record: service:http_requests_total:rate1h expr: sum by (service) (rate(http_requests_total[1h])) - record: cluster:http_requests_total:rate5m expr: sum(rate(http_requests_total[5m])) # Latency metrics - name: latency_metrics interva
Prometheus
prometheus.io › docs › prometheus › latest › configuration › configuration
Configuration | Prometheus
[ evaluation_interval: <duration> | default = 1m ] # Offset the rule evaluation timestamp of this particular group by the # specified duration into the past to ensure the underlying metrics have # been received. Metric availability delays are more likely to occur when # Prometheus is running as a remote write target, but can also occur when # there's anomalies with scraping.
Samber
samber.github.io › home › rules
1162 Prometheus Alerting Rules for 94 Services | Awesome Prometheus Alerts
Browse 1162 Prometheus alerting rules across 94 services. Organized by category: databases, Kubernetes, cloud providers, message brokers, and more.