-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
65 changes: 65 additions & 0 deletions
65
...c/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/prometheus-rule.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ https://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<configuration> | ||
<property> | ||
<name>rules_file_name</name> | ||
<value>prometheus_rules.yml</value> | ||
<description>Rules file name</description> | ||
</property> | ||
<property> | ||
<name>content</name> | ||
<description>This is the freemarker template for rules file</description> | ||
<value><![CDATA[ | ||
groups: | ||
# Recording rules group: Used to calculate and save new aggregated metrics | ||
- name: example_recording_rules | ||
interval: 1m # The frequency at which the rules are evaluated | ||
rules: | ||
# Recording rule: Calculate the average CPU usage over the last 5 minutes for each job | ||
- record: job:cpu_usage:avg | ||
expr: avg(rate(node_cpu_seconds_total{mode="user"}[5m])) by (job) | ||
# This creates a new metric `job:cpu_usage:avg` representing the average CPU usage per job | ||
# Alerting rules group: Used to trigger alerts based on conditions | ||
- name: example_alerting_rules | ||
interval: 1m # The frequency at which the alerting rules are evaluated | ||
rules: | ||
# Alerting rule: Trigger an alert if the average CPU usage is over 90% for the last 5 minutes | ||
- alert: HighCpuUsage | ||
expr: avg(rate(node_cpu_seconds_total{mode="user"}[5m])) by (instance) > 0.9 | ||
# This expression checks if the average CPU usage over the last 5 minutes for each instance is greater than 90% | ||
for: 5m # The condition must hold true for 5 minutes before the alert is triggered | ||
labels: | ||
severity: critical # Set the severity of the alert as 'critical' | ||
annotations: | ||
summary: "CPU usage on instance {{ $labels.instance }} is over 90% for the last 5 minutes" | ||
# Summary of the alert that will appear when it triggers | ||
description: "The CPU usage on instance {{ $labels.instance }} has been over 90% for the past 5 minutes." | ||
# Detailed description of the alert that will provide more context | ||
]]> | ||
</value> | ||
<attrs> | ||
<type>longtext</type> | ||
</attrs> | ||
</property> | ||
</configuration> |
This file contains 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
This file contains 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