Skip to content

Commit

Permalink
fix(config/grafana): use range for HPA metrics
Browse files Browse the repository at this point in the history
Use range instead of instant for HPA current/max replicas (time based).

Right now, we are using the instant selector, which given that the panel
should be time-based (as per the title), it should use a range selector,
thus getting all metrics in a given timeframe.

Also, moved from bars to lines because bars are hard to visualize using
ranges containing several days worth of data.

Signed-off-by: Ricardo Ribeiro <j.ribeiro.fafe@gmail.com>
  • Loading branch information
jrRibeiro committed May 2, 2023
1 parent 9d22b0c commit 5baa4ef
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 122 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ jobs:
with:
secrets: ${{ toJSON(secrets) }}

- name: Scale cluster
run: make scale-node-pool
env:
NODE_POOL_SIZE: 4

- name: Run end to end tests
continue-on-error: true
id: test
Expand All @@ -152,6 +157,12 @@ jobs:
env:
TEST_CLUSTER_NAME: keda-pr-run

- name: Scale cluster
if: ${{ always() }}
run: make scale-node-pool
env:
NODE_POOL_SIZE: 1

- name: React to comment with success
uses: dkershner6/reaction-action@v1
if: steps.test.outcome == 'success'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/template-main-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
with:
secrets: ${{ toJSON(secrets) }}

- name: Scale cluster
run: make scale-node-pool
env:
NODE_POOL_SIZE: 4

- name: Run end to end tests
env:
AWS_RUN_IDENTITY_TESTS: true
Expand All @@ -35,6 +40,12 @@ jobs:
if: ${{ always() }}
run: make e2e-test-clean

- name: Scale cluster
if: ${{ always() }}
run: make scale-node-pool
env:
NODE_POOL_SIZE: 1

- name: Upload test logs
uses: actions/upload-artifact@v3
if: ${{ always() }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **Azure Pipelines**: Fix for disallowing `$top` on query when using `meta.parentID` method ([#4397])
- **Azure Pipelines**: Respect all required demands ([#4404](https://github.com/kedacore/keda/issues/4404))
- **Prometheus Metrics**: Create e2e tests for all exposed Prometheus metrics ([#4127](https://github.com/kedacore/keda/issues/4127))
- **Grafana Dashboard**: Fix HPA metrics panel to use range instead of instant ([#4511](https://github.com/kedacore/keda/pull/4511))

### Deprecations

Expand All @@ -74,6 +75,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

- **General**: Drop a transitive dependency on bou.ke/monkey ([#4364](https://github.com/kedacore/keda/issues/4364))
- **General**: Fix odd number of arguments passed as key-value pairs for logging ([#4368](https://github.com/kedacore/keda/issues/4368))
- **General**: Automatically scale test clusters in/out to reduce environmental footprint & improve cost-efficiency ([#4456](https://github.com/kedacore/keda/pull/4456))

## v2.10.0

Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S")

TEST_CLUSTER_NAME ?= keda-nightly-run-3
NODE_POOL_SIZE ?= 1
NON_ROOT_USER_ID ?= 1000

GCP_WI_PROVIDER ?= projects/${TF_GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${TEST_CLUSTER_NAME}/providers/${TEST_CLUSTER_NAME}
Expand Down Expand Up @@ -81,14 +82,25 @@ install-test-deps:
test: manifests generate fmt vet envtest install-test-deps ## Run tests and export the result to junit format.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v 2>&1 ./... -coverprofile cover.out | go-junit-report -iocopy -set-exit-code -out report.xml

.PHONY: get-cluster-context
get-cluster-context: ## Get Azure cluster context.
.PHONY:
az-login:
@az login --service-principal -u $(TF_AZURE_SP_APP_ID) -p "$(AZURE_SP_KEY)" --tenant $(TF_AZURE_SP_TENANT)

.PHONY: get-cluster-context
get-cluster-context: az-login ## Get Azure cluster context.
@az aks get-credentials \
--name $(TEST_CLUSTER_NAME) \
--subscription $(TF_AZURE_SUBSCRIPTION) \
--resource-group $(TF_AZURE_RESOURCE_GROUP)

.PHONY: scale-node-pool
scale-node-pool: az-login ## Scale nodepool.
@az aks scale \
--name $(TEST_CLUSTER_NAME) \
--subscription $(TF_AZURE_SUBSCRIPTION) \
--resource-group $(TF_AZURE_RESOURCE_GROUP) \
--node-count $(NODE_POOL_SIZE)

.PHONY: e2e-test
e2e-test: get-cluster-context ## Run e2e tests against Azure cluster.
TERMINFO=/etc/terminfo
Expand Down
22 changes: 14 additions & 8 deletions config/grafana/keda-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,18 +735,23 @@
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"drawStyle": "line",
"fillOpacity": 100,
"gradientMode": "hue",
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
Expand All @@ -756,7 +761,7 @@
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
Expand Down Expand Up @@ -787,7 +792,8 @@
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
Expand All @@ -804,10 +810,10 @@
"exemplar": false,
"expr": "kube_horizontalpodautoscaler_status_current_replicas{namespace=\"$namespace\",horizontalpodautoscaler=\"keda-hpa-$scaledObject\"}",
"format": "time_series",
"instant": true,
"instant": false,
"interval": "",
"legendFormat": "current_replicas",
"range": false,
"range": true,
"refId": "A"
},
{
Expand All @@ -820,9 +826,9 @@
"expr": "kube_horizontalpodautoscaler_spec_max_replicas{namespace=\"$namespace\",horizontalpodautoscaler=\"keda-hpa-$scaledObject\"}",
"format": "time_series",
"hide": false,
"instant": true,
"instant": false,
"legendFormat": "max_replicas",
"range": false,
"range": true,
"refId": "B"
}
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/gcp_pubsub_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (s *pubsubScaler) GetMetricsAndActivity(ctx context.Context, metricName str

value, err := s.getMetrics(ctx, metricType)
if err != nil {
s.logger.Error(err, "error getting metric", metricType)
s.logger.Error(err, "error getting metric", "metricType", metricType)
return []external_metrics.ExternalMetricValue{}, false, err
}

Expand Down
Loading

0 comments on commit 5baa4ef

Please sign in to comment.