1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/bin/sh
# PCP QA Test No. 1787
# Test pmdaopentelemetry label filtering, including optional labels
#
# Copyright (c) 2025 Red Hat. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.opentelemetry
_pmdaopentelemetry_check || _notrun "opentelemetry pmda and/or load generator not installed"
status=1 # failure is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
_cleanup()
{
cd $here
$sudo rm -rf $PCP_ETC_DIR/pcp/labels/*
_restore_config $PCP_ETC_DIR/pcp/labels
_sighup_pmcd
_pmdaopentelemetry_cleanup
$sudo rm -rf $tmp $tmp.*
}
_prepare_pmda opentelemetry
trap "_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd
_filter()
{
# Filter a bunch of labels that we dont want for QA purposes
sed \
-e 's/"domainname":"[^"]*"//' \
-e 's/"groupid":[0-9]*//' \
-e 's/"userid":[0-9]*//' \
-e 's/"hostname":"[^"]*"//' \
-e 's/"machineid":"[^"]*"//' \
-e 's/"url":"[^"]*"//' \
-e 's/,[,]*/,/g' -e 's/,}/}/'
}
# real QA test starts here
_pmdaopentelemetry_save_config
_save_config $PCP_ETC_DIR/pcp/labels
$sudo rm -rf $PCP_ETC_DIR/pcp/labels/*
# add the URL for this test
file=$here/opentelemetry/samples/labelfiltering.txt
urlbase=`basename $file .txt | tr .- _`
echo 'file://'$file > $PCP_PMDAS_DIR/opentelemetry/config.d/$urlbase.url
# add a bunch of label filters to exercise various filtering options
cat <<EOF >>$PCP_PMDAS_DIR/opentelemetry/config.d/$urlbase.url
# Filter to remove the "uninteresting" label
FILTER: EXCLUDE LABEL random
# Filter to remove all labels in metric2, thus it becomes singular
#FILTER: EXCLUDE LABEL removeme
# Filter to exclude label "def" hence metric3 has duplicate instances
#FILTER: EXCLUDE LABEL def
#
# *** NOTE: optional labels are not implemented yet
# Filter to flag some_optional_label as optional in metric4
# (an optional label is not present in instance name, but still included as a label for the metric)
# FILTER: OPTIONAL LABEL some_optional_label
# implicit final rule includes all labels not matching anything above
# (this implicit rule is listed here just for testing purposes)
#FILTER: INCLUDE .*
EOF
_pmdaopentelemetry_install
if ! _pmdaopentelemetry_wait_for_metric opentelemetry.control.calls
then
status=1
exit
fi
echo; echo === URL configuration file contains
sed -e "s|$here|QA_DIR|g" < $PCP_PMDAS_DIR/opentelemetry/config.d/$urlbase.url
echo; echo === pminfo listing. Note some labels in the pminfo listing have been removed, see _filter
names=`pminfo opentelemetry | grep -F -v opentelemetry.control | LC_COLLATE=POSIX sort` 2>$tmp.err
if [ -z "$names" ]; then
echo "FAILED - no opentelemetry metrics to show"
else
if pminfo -fl `pminfo opentelemetry | grep -F -v opentelemetry.control | LC_COLLATE=POSIX sort` > $tmp.info 2>$tmp.err
then
:
else
echo "... failed! ... here is the Install log ..."
cat $tmp.out
fi
cat $tmp.info $tmp.err | _filter
fi
echo == Note: check $seq.full for details
echo == pmdaopentelemetry LOG == >>$here/$seq.full
cat $PCP_LOG_DIR/pmcd/opentelemetry.log >>$here/$seq.full
_pmdaopentelemetry_remove
# success, all done
status=0
exit
|