Skip to content

Commit

Permalink
Add option to define base federated metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodor committed Feb 13, 2024
1 parent 4d74ddf commit 5446394
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ If you make changes to Alerts, Recording rules, or Grafana dashboards, and if th
* Run `make generate-federate` to update federation config.
* And commit changes in `resources/prometheus/federation-config.yaml` file to the repo.

You can add additional federated metrics that are not used in any Alert, Recording rule, or Grafana dashboard to `resources/prometheus/federation-config-base.yaml,` and they will be merged with other metrics. Always add a comment with the reason why metrics are added to the base list.

### 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
6 changes: 3 additions & 3 deletions resources/prometheus/federation-config.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion scripts/generate-federate-match.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function main() {
sort "${metrics_list_file}" | uniq | grep -v -E "^acs|^rox|^aws|^central:|acscs_worker_nodes" | awk '{ print $1 "{job!~\"central|scanner\"}" }' > "${metrics_list_file}.filter"

# Create federation-config.yaml
sed -e 's/^/- /' "${metrics_list_file}.filter" | yq '{ "match[]": . }' > "${repo_dir}/resources/prometheus/federation-config.yaml"
local yq_expression='. *+ load("'"${repo_dir}/resources/prometheus/federation-config-base.yaml"'")."match[]" | unique | sort | { "match[]": . }'
sed -e 's/^/- /' "${metrics_list_file}.filter" | yq "${yq_expression}" > "${repo_dir}/resources/prometheus/federation-config.yaml"

# Clean up the temp directory with all transient files
rm -rf "${working_tmp_dir}"
Expand Down

0 comments on commit 5446394

Please sign in to comment.