sassoftware / viya4-monitoring-kubernetes

Provides simple scripts and customization options to deploy monitoring, alerts, and log aggregation for Viya 4 running on Kubernetes
Apache License 2.0
50 stars 31 forks source link

Tempo perf tweaks #636

Closed ceelias closed 1 month ago

github-actions[bot] commented 1 month ago

sh-checker report

To get the full details, please check in the job output.

shellcheck errors ``` 'shellcheck -e SC1004' returned error 1 finding the following syntactical issues: ---------- In monitoring/bin/deploy_dashboards.sh line 6: cd "$(dirname $BASH_SOURCE)/../.." ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element. ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: cd "$(dirname "$BASH_SOURCE")/../.." In monitoring/bin/deploy_dashboards.sh line 7: source monitoring/bin/common.sh ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x). In monitoring/bin/deploy_dashboards.sh line 35: for f in $dir/*.json; do ^--^ SC2231 (info): Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt . In monitoring/bin/deploy_dashboards.sh line 40: name=$(basename $f .json) ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: name=$(basename "$f" .json) In monitoring/bin/deploy_dashboards.sh line 42: kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: kubectl create cm -n "$DASH_NS" "$name" --dry-run=client --from-file "$f" -o yaml | kubectl apply --server-side -f - In monitoring/bin/deploy_dashboards.sh line 43: kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=$type ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: kubectl label cm -n "$DASH_NS" "$name" --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType="$type" In monitoring/bin/deploy_dashboards.sh line 57: name=$(basename $f .json) ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: name=$(basename "$f" .json) In monitoring/bin/deploy_dashboards.sh line 58: kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: kubectl create cm -n "$DASH_NS" "$name" --dry-run=client --from-file "$f" -o yaml | kubectl apply --server-side -f - In monitoring/bin/deploy_dashboards.sh line 59: kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=manual ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: kubectl label cm -n "$DASH_NS" "$name" --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=manual For more information: https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... https://www.shellcheck.net/wiki/SC1091 -- Not following: monitoring/bin/com... https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... ---------- You can address the above issues in one of three ways: 1. Manually correct the issue in the offending shell script; 2. Disable specific issues by adding the comment: # shellcheck disable=NNNN above the line that contains the issue, where NNNN is the error code; 3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file. ```
shfmt errors ``` 'shfmt -s' returned error 1 finding the following formatting issues: ---------- --- bin/kube-include.sh.orig +++ bin/kube-include.sh @@ -7,8 +7,8 @@ # Assumes bin/common.sh has been sourced if [ ! "$(which kubectl)" ]; then - log_error "kubectl not found on the current PATH" - exit 1 + log_error "kubectl not found on the current PATH" + exit 1 fi KUBE_CLIENT_VER=$(kubectl version --short | grep 'Client Version' | awk '{print $3}' 2>/dev/null) @@ -16,10 +16,10 @@ # Client version allowed to be one minor version earlier than minimum server version if [[ $KUBE_CLIENT_VER =~ v1.2[0-9] ]]; then - : -else - log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]." - log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version." + : +else + log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]." + log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version." fi # SAS Viya 4 versions @@ -34,10 +34,10 @@ # 2024.04 1.26 1.28 if [[ $KUBE_SERVER_VER =~ v1.2[1-9] ]]; then - : -else - log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya." - log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version." + : +else + log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya." + log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version." fi export KUBE_CLIENT_VER="$KUBE_CLIENT_VER" --- monitoring/bin/deploy_dashboards.sh.orig +++ monitoring/bin/deploy_dashboards.sh @@ -25,108 +25,108 @@ DASH_BASE="${DASH_BASE:-monitoring/dashboards}" function deploy_dashboards { - type=$1 - if [ -z "$2" ]; then - dir=$"$DASH_BASE/$type" - else - dir=$2 - fi - - for f in $dir/*.json; do - # Need to check existence because if there are no matching files, - # f will include the wildcard character (*) - if [ -f "$f" ]; then - log_debug "Deploying dashboard from file [$f]" - name=$(basename $f .json) - - kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - - kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=$type - fi - done + type=$1 + if [ -z "$2" ]; then + dir=$"$DASH_BASE/$type" + else + dir=$2 + fi + + for f in $dir/*.json; do + # Need to check existence because if there are no matching files, + # f will include the wildcard character (*) + if [ -f "$f" ]; then + log_debug "Deploying dashboard from file [$f]" + name=$(basename $f .json) + + kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - + kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=$type + fi + done } # Single argument supported. If specified, deploy either the specified .json # file as a dashboard or all .json files in the specified directory if [ "$1" != "" ]; then - if [ -f "$1" ]; then - if [[ $1 =~ .+\.json ]]; then - # Deploy single dashboard - f=$1 - log_info "Deploying Grafana dashboard [$f]" - name=$(basename $f .json) - kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - - kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=manual - exit $? - else - log_error "[$1] is not a Grafana dashboard .json file" - exit 1 - fi - fi + if [ -f "$1" ]; then + if [[ $1 =~ .+\.json ]]; then + # Deploy single dashboard + f=$1 + log_info "Deploying Grafana dashboard [$f]" + name=$(basename $f .json) + kubectl create cm -n $DASH_NS $name --dry-run=client --from-file $f -o yaml | kubectl apply --server-side -f - + kubectl label cm -n $DASH_NS $name --overwrite grafana_dashboard=1 sas.com/monitoring-base=kube-viya-monitoring sas.com/dashboardType=manual + exit $? + else + log_error "[$1] is not a Grafana dashboard .json file" + exit 1 + fi + fi - if [ -d "$1" ]; then - # Deploy specified directory of dashboards - log_verbose "Deploying Grafana dashboards in [$1]" - deploy_dashboards "manual" "$1" - exit $? - fi + if [ -d "$1" ]; then + # Deploy specified directory of dashboards + log_verbose "Deploying Grafana dashboards in [$1]" + deploy_dashboards "manual" "$1" + exit $? + fi - log_error "The dashboard path [$1] does not exist" - exit 1 + log_error "The dashboard path [$1] does not exist" + exit 1 fi log_info "Deploying dashboards to the [$DASH_NS] namespace ..." if [ "$WELCOME_DASH" == "true" ]; then - log_verbose "Deploying welcome dashboards" - deploy_dashboards "welcome" + log_verbose "Deploying welcome dashboards" + deploy_dashboards "welcome" fi if [ "$KUBE_DASH" == "true" ]; then - log_verbose "Deploying Kubernetes cluster dashboards" - deploy_dashboards "kube" + log_verbose "Deploying Kubernetes cluster dashboards" + deploy_dashboards "kube" fi if [ "$ISTIO_DASH" == "true" ]; then - log_verbose "Deploying Istio dashboards" - deploy_dashboards "istio" + log_verbose "Deploying Istio dashboards" + deploy_dashboards "istio" fi if [ "$LOGGING_DASH" == "true" ]; then - log_verbose "Deploying Logging dashboards" - deploy_dashboards "logging" + log_verbose "Deploying Logging dashboards" + deploy_dashboards "logging" fi if [ "$VIYA_DASH" == "true" ]; then - log_verbose "Deploying SAS Viya dashboards" - deploy_dashboards "viya" + log_verbose "Deploying SAS Viya dashboards" + deploy_dashboards "viya" fi if [ "$VIYA_LOGS_DASH" == "true" ]; then - log_verbose "Deploying SAS Viya dashboards with log support" - deploy_dashboards "viya-logs" + log_verbose "Deploying SAS Viya dashboards with log support" + deploy_dashboards "viya-logs" fi if [ "$PGMONITOR_DASH" == "true" ]; then - log_verbose "Deploying Postgres dashboards" - deploy_dashboards "pgmonitor" + log_verbose "Deploying Postgres dashboards" + deploy_dashboards "pgmonitor" fi if [ "$RABBITMQ_DASH" == "true" ]; then - log_verbose "Deploying RabbitMQ dashboards" - deploy_dashboards "rabbitmq" + log_verbose "Deploying RabbitMQ dashboards" + deploy_dashboards "rabbitmq" fi if [ "$NGINX_DASH" == "true" ]; then - log_verbose "Deploying NGINX dashboards" - deploy_dashboards "nginx" + log_verbose "Deploying NGINX dashboards" + deploy_dashboards "nginx" fi if [ "$USER_DASH" == "true" ]; then - userDashDir="$USER_DIR/monitoring/dashboards" - if [ -d "$userDashDir" ]; then - log_verbose "Deploying user dashboards from [$userDashDir]" - deploy_dashboards "user" "$userDashDir" - fi + userDashDir="$USER_DIR/monitoring/dashboards" + if [ -d "$userDashDir" ]; then + log_verbose "Deploying user dashboards from [$userDashDir]" + deploy_dashboards "user" "$userDashDir" + fi fi log_info "Deployed dashboards to the [$DASH_NS] namespace" ---------- You can reformat the above files to meet shfmt's requirements by typing: shfmt -s -w filename ```