-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for RabbitMQ alerting without depending on Prometheus Ope…
…rator (#676) * Integrate RabbitMQ Alerting without Prometheus Operator Before this commit, RabbitMQ Alerting was set up with the assumption that Prometheus Operator is installed. However, many K8s clusters have Prometheus installed without using Prometheus Operator. Therefore, support RabbitMQ alerting integration with and without using Prometheus Operator. Auto-generate single Prometheus rule file from PrometheusRules. Add Prometheus RabbitMQ scrape targets (do not rely on outdated annotation approach). * Remove line to set dev image since v1.7.0 will be cut very soon * Make clear that Prometheus CRDs can be put in any namespace ...NamespaceSelector {} means any namespace will be selected. This is not to be confused with value `nil` which means "only check own namespace". * Skip SSL verification in dev setup
- Loading branch information
Showing
15 changed files
with
620 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "Prometheus Rules" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- observability/prometheus/rules/**/*.y*ml | ||
jobs: | ||
rules: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Create Prometheus rule file | ||
run: | | ||
export GOPATH=$HOME/go | ||
export PATH=$PATH:$GOPATH/bin | ||
make install-tools | ||
cd observability/prometheus/ | ||
echo "# This file got auto-generated by GitHub workflow '$GITHUB_WORKFLOW'" > rule-file.yml | ||
cat >> rule-file.yml << EOF | ||
--- | ||
groups: | ||
- name: rabbitmq-cluster-operator | ||
rules: [] | ||
- name: rabbitmq | ||
rules: [] | ||
EOF | ||
find rules/rabbitmq-cluster-operator -name "*.y*ml" -exec yq eval-all --inplace --no-colors --prettyPrint 'select(fileIndex==0).groups.[0].rules = select(fileIndex==0).groups.[0].rules + select(fileIndex==1).spec.groups.[0].rules | select(fileIndex==0)' rule-file.yml {} ';' | ||
append_rabbitmq_rules='select(fileIndex==0).groups.[1].rules = select(fileIndex==0).groups.[1].rules + select(fileIndex==1).spec.groups.[0].rules | select(fileIndex==0)' | ||
find rules/rabbitmq -name "*.y*ml" ! -name recording-rules.yml -exec yq eval-all --inplace --no-colors --prettyPrint "$append_rabbitmq_rules" rule-file.yml {} ';' | ||
yq eval-all --inplace --no-colors --prettyPrint "$append_rabbitmq_rules" rule-file.yml rules/rabbitmq/recording-rules.yml | ||
- name: Check Prometheus rule file | ||
run: | | ||
export GOPATH=$HOME/go | ||
export PATH=$PATH:$GOPATH/bin | ||
# need to use @main because of https://github.com/prometheus/prometheus/issues/8586#issuecomment-796976710 | ||
GO111MODULE=on go get github.com/prometheus/prometheus/cmd/promtool@main | ||
promtool check rules observability/prometheus/rule-file.yml | ||
- name: Commit Prometheus rule file | ||
working-directory: observability/prometheus | ||
run: | | ||
if [[ `git status --porcelain -- rule-file.yml` ]]; then | ||
git config --global user.name 'RabbitMQ CI Bot' | ||
git config --global user.email '[email protected]' | ||
git add -- rule-file.yml | ||
git commit -m "Update Prometheus rule file" | ||
git push | ||
fi |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Prometheus configuration | ||
|
||
RabbitMQ alerting rules depend on [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics). Refer to the kube-state-metrics documentation to deploy and scrape kube-state-metrics. | ||
|
||
## With Prometheus Operator | ||
If Prometheus and Alertmanager are installed by [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator), apply the YAML files in [alertmanager](./alertmanager), [monitors](./monitors), and [rules](./rules) directories. They contain K8s objects watched by Prometheus Operator configuring Prometheus. | ||
|
||
## Without Prometheus Operator | ||
If Prometheus and Alertmanager are not installed by Prometheus Operator, use [config-file.yml](./config-file.yml) and [rule-file.yml](./rule-file.yml) as a starting point for RabbitMQ monitoring and alerting. | ||
`rule-file.yml` is an auto-generated file containing the same rules as the [rules](./rules/) directory. | ||
|
||
For the [Alertmanager configuration file](https://prometheus.io/docs/alerting/latest/configuration/#configuration-file), use the same `alertmanager.yaml` as provided in [alertmanager/slack.yml](alertmanager/slack.yml). |
Oops, something went wrong.