mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-01-09 15:59:29 +00:00
Add metric change tracking scripts.
This commit is contained in:
parent
a2a2a1df2d
commit
df0bb41a13
@ -22,6 +22,8 @@ after_success:
|
||||
; docker push wrouesnel/postgres_exporter:$TRAVIS_TAG ; fi
|
||||
- if [ "$TRAVIS_BRANCH" == "master" ]; then docker push wrouesnel/postgres_exporter
|
||||
; fi
|
||||
- ./postgres-metrics-get-changes.sh
|
||||
- if [ "$TRAVIS_BRANCH" == "support_shell_fixes" ]; then ./gh-metrics-push.sh ; fi
|
||||
env:
|
||||
global:
|
||||
- DOCKER_USER=wrouesnel
|
||||
|
@ -2,8 +2,8 @@
|
||||
# Script to setup the assets clone of the repository using GIT_ASSETS_BRANCH and
|
||||
# GIT_API_KEY.
|
||||
|
||||
[ -z "$GIT_ASSETS_BRANCH" ] || exit 1
|
||||
[ -z "$GIT_API_KEY" ] || exit 1
|
||||
[ ! -z "$GIT_ASSETS_BRANCH" ] || exit 1
|
||||
[ ! -z "$GIT_API_KEY" ] || exit 1
|
||||
|
||||
setup_git() {
|
||||
git config --global user.email "travis@travis-ci.org" || exit 1
|
||||
|
29
gh-metrics-push.sh
Executable file
29
gh-metrics-push.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# Script to copy and push new metric versions to the assets branch.
|
||||
|
||||
[ ! -z "$GIT_ASSETS_BRANCH" ] || exit 1
|
||||
[ ! -z "$GIT_API_KEY" ] || exit 1
|
||||
|
||||
version=$(git describe HEAD) || exit 1
|
||||
|
||||
# Constants
|
||||
ASSETS_DIR=".assets-branch"
|
||||
METRICS_DIR="$ASSETS_DIR/metriclists"
|
||||
|
||||
# Ensure metrics dir exists
|
||||
mkdir -p "$METRICS_DIR/"
|
||||
|
||||
# Remove old files so we spot deletions
|
||||
rm -f "$METRICS_DIR/*.unique"
|
||||
|
||||
# Copy new files
|
||||
cp -f -t "$METRICS_DIR/" ./*.unique || exit 1
|
||||
|
||||
# Enter the assets dir and push.
|
||||
cd "$ASSETS_DIR" || exit 1
|
||||
|
||||
git add "$METRICS_DIR" || exit 1
|
||||
git commit -m "Added unique metrics for build from $version" || exit 1
|
||||
git push origin "$GIT_ASSETS_BRANCH" || exit 1
|
||||
|
||||
exit 0
|
34
postgres-metrics-get-changes.sh
Executable file
34
postgres-metrics-get-changes.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# Script to parse a text exposition format file into a unique list of metrics
|
||||
# output by the exporter and then build lists of added/removed metrics.
|
||||
|
||||
old_src="$1"
|
||||
[ ! -e "$old_src" ] && exit 1
|
||||
|
||||
function generate_add_removed() {
|
||||
type="$1"
|
||||
pg_version="$2"
|
||||
old_version="$3"
|
||||
new_version="$4"
|
||||
|
||||
comm -23 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.removed"
|
||||
comm -13 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.added"
|
||||
}
|
||||
|
||||
for raw_prom in $(echo .*.prom) ; do
|
||||
# Get the type and version
|
||||
type=$(cut -d'.' -f3)
|
||||
pg_version=$(cut -d'.' -f4)
|
||||
|
||||
unique_file="${raw_prom}.unique"
|
||||
old_unique_file="$old_src/$unique_file"
|
||||
|
||||
# Strip, sort and deduplicate the label names
|
||||
grep -v '#' "$raw_prom" | \
|
||||
rev | cut -d' ' -f2- | \
|
||||
rev | cut -d'{' -f1 | \
|
||||
sort | \
|
||||
uniq > "$unique_file"
|
||||
|
||||
generate_add_removed "$type" "$pg_version" "$old_unique_file" "$unique_file"
|
||||
done
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Script to determine added and removed metrics.
|
||||
# Not currently used in CI but useful for inspecting complicated changes.
|
||||
|
||||
# valid types: single or replicated
|
||||
type="$1"
|
||||
pg_version="$2"
|
||||
old_version="$3"
|
||||
new_version="$4"
|
||||
|
||||
comm -23 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.removed"
|
||||
comm -13 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.added"
|
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Script to parse a text exposition format file into a unique list of metrics
|
||||
# output by the exporter.
|
||||
|
||||
# Not currently used for CI, but useful for inspecting the differences of
|
||||
# complicated PRs.
|
||||
|
||||
for raw_prom in $(echo .*.prom) ; do
|
||||
# Strip, sort and deduplicate the label names
|
||||
grep -v '#' "$raw_prom" | \
|
||||
rev | cut -d' ' -f2- | \
|
||||
rev | cut -d'{' -f1 | \
|
||||
sort | \
|
||||
uniq > "${raw_prom}.unique"
|
||||
done
|
Loading…
Reference in New Issue
Block a user