From 455d82311626b4ca46a258c4e54f3ceab368d218 Mon Sep 17 00:00:00 2001 From: Mladen Todorovic Date: Wed, 13 Dec 2023 18:29:31 +0100 Subject: [PATCH] Added GH actions check, added make option and improved README --- .../workflows/validate-federated-metrics.yml | 18 ++++++++++++++++++ Makefile | 11 +++++++++-- README.md | 14 ++++++++++++++ scripts/generate-federate-match.sh | 8 +------- 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/validate-federated-metrics.yml diff --git a/.github/workflows/validate-federated-metrics.yml b/.github/workflows/validate-federated-metrics.yml new file mode 100644 index 00000000..4ef25460 --- /dev/null +++ b/.github/workflows/validate-federated-metrics.yml @@ -0,0 +1,18 @@ +name: Validate Generated +on: + push: + branches: [master] + pull_request: +jobs: + validate-federated-metrics: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Validate federated metrics + run: | + curl --silent --show-error --fail --location https://github.com/grafana/mimir/releases/download/mimir-2.10.5/mimirtool-linux-amd64 --output /usr/local/bin/mimirtool + echo "72f46c82c303c48566844612f83ab53d4b804c665644163ad7f0f8945caa0521 /usr/local/bin/mimirtool" | sha256sum --check --status + chmod +x /usr/local/bin/mimirtool + cp "${GITHUB_WORKSPACE}/resources/prometheus/federation-config.yaml" "/tmp/federation-config.yaml" + make -C "${GITHUB_WORKSPACE}" generate-federate + cmp "/tmp/federation-config.yaml" "${GITHUB_WORKSPACE}/resources/prometheus/federation-config.yaml" --silent || { echo "Please update 'federation-config.yaml' by running: 'make generate-federate'."; exit 1; } diff --git a/Makefile b/Makefile index 4789bae4..b5020a16 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,15 @@ -.PHONY: generate -generate: +.PHONY: generate-resources +generate-resources: $(MAKE) -C resources/mixins/kubernetes generate $(MAKE) -C resources/grafana generate +.PHONY: generate-federate +generate-federate: + @scripts/generate-federate-match.sh + +.PHONY: generate +generate: generate-resources generate-federate + .PHONY: update update: $(MAKE) -C resources/mixins/kubernetes update diff --git a/README.md b/README.md index aec9924a..0a15e11a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,13 @@ GitHub actions to trigger branch synchronization. ## Contributing +### Prerequisites + +The following tools are required for development: +- `jq` - please follow [the installation instructions](https://jqlang.github.io/jq/download). +- `mimirtool` - please follow [the installation instructions](https://grafana.com/docs/mimir/latest/manage/tools/mimirtool/#installation). +- `yq` - please follow [the installation instructions](https://github.com/mikefarah/yq/#install). + ### Dashboards To make changes to the rhacs dashboards: @@ -48,6 +55,13 @@ Then: * Update `resources/mixins/kubernetes/mixin.libsonnet`. * Run `make generate` to generate the corresponding mixin resources. +### Federated metrics + +If you make changes to Alerts or Recording rules and if they include metrics collected by OSD Prometheus, ensure that the federation config includes new metrics. + +* Run `make generate-federate` to update federation config. +* And commit changes in `resources/prometheus/federation-config.yaml` file to the repo. + ### Pre-commit hook This repository makes use of [pre-commit](https://pre-commit.com/) framework. Refer to the [installation instructions](https://pre-commit.com/#installation) for further information. diff --git a/scripts/generate-federate-match.sh b/scripts/generate-federate-match.sh index 38d0aa5d..014c5f28 100755 --- a/scripts/generate-federate-match.sh +++ b/scripts/generate-federate-match.sh @@ -1,11 +1,5 @@ #!/usr/bin/env bash -# TODO: -# - add entry in Makefile -# - get metrics needed for combined dashboards -# - create CI step that will fail if federated yaml in repo is different from generated one -# (to cover case where someone forgets to re-generate it locally) - set -eou pipefail shopt -s inherit_errexit @@ -19,7 +13,6 @@ function log_exit() { exit 1 } - function check_command() { local cmd="${1:-}" @@ -98,6 +91,7 @@ function main() { # Clean up the temp directory with all transient files rm -rf "${working_tmp_dir}" + log "Deleted temp dir: '${working_tmp_dir}'" } main "$@"