Create a rules file
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 has the same format as a rules file in standalone Prometheus. For
more information, see Defining Recording rules
The following is a basic example of a rules file:
groups: - name: test rules: - record: metric:recording_rule expr: avg(rate(container_cpu_usage_seconds_total[5m])) - name: alert-test rules: - alert: metric:alerting_rule expr: avg(rate(container_cpu_usage_seconds_total[5m])) > 0 for: 2m
For more alerting rule examples, see Alerting rule
examples
Note
You can create a rules definition file locally and then upload it to Amazon Managed Service for Prometheus, or you can create, edit and upload the definition directly within the Amazon Managed Service for Prometheus console. Either way, the same formatting rules apply. To learn more about uploading and editing your file, see Upload a rules configuration file to Amazon Managed Service for Prometheus.