Skip to content

Commit

Permalink
Added GH actions check, added make option and improved README
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodor committed Dec 13, 2023
1 parent d516379 commit 455d823
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/validate-federated-metrics.yml
Original file line number Diff line number Diff line change
@@ -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; }
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
8 changes: 1 addition & 7 deletions scripts/generate-federate-match.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -19,7 +13,6 @@ function log_exit() {
exit 1
}


function check_command() {
local cmd="${1:-}"

Expand Down Expand Up @@ -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 "$@"

0 comments on commit 455d823

Please sign in to comment.