keda icon indicating copy to clipboard operation
keda copied to clipboard

feat: Dynatrace scaler

Open cyrilico opened this issue 4 months ago • 24 comments

Add new scaler for interacting with Dynatrace and its Get Metric Data Points API

Checklist

Closes #2411

Relates to https://github.com/kedacore/keda-docs/pull/1360

cyrilico avatar Apr 11 '24 14:04 cyrilico

/run-e2e dynatrace Update: You can check the progress here

zroubalik avatar Apr 24 '24 19:04 zroubalik

Please, rebase your branch @cyrilico , the e2e issue was related with some breaking changes in otel-collector which are already fixed in main branch (your tests hasn't been executed yet indeed)

JorTurFer avatar Apr 28 '24 10:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 10:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 14:04 JorTurFer

new changes, please rerun

cyrilico avatar Apr 28 '24 17:04 cyrilico

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 17:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 21:04 JorTurFer

@cyrilico I've merged 2 fixes to the e2e to trigger them again (you'll need to pull the changes :) )

JorTurFer avatar Apr 28 '24 21:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 21:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 28 '24 22:04 JorTurFer

It seems that the query isn't correct. Checking the logs I see lines like this:

2024-04-28T22:27:24Z	ERROR	dynatrace_scaler	error executing Dynatrace query	{"type": "ScaledObject", "namespace": "dynatrace-test-ns", "name": "dynatrace-test-so", "error": "dynatrace response does not contain any results"}

JorTurFer avatar Apr 28 '24 22:04 JorTurFer

I misnamed a response property name which must have caused the inability to correctly parse it, not sure where I got the original from, probably misread; the query itself is pretty generic, should always return something

cyrilico avatar Apr 29 '24 13:04 cyrilico

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 29 '24 18:04 JorTurFer

2024-04-29T19:24:29.2272752Z === RUN   TestDynatraceScaler
2024-04-29T19:24:29.2276455Z     dynatrace_test.go:***9: --- setting up ---
2024-04-29T19:24:29.2280365Z     helper.go:***48: deleting namespace dynatrace-test-ns
2024-04-29T19:24:29.2299743Z     helper.go:***0***: waiting for namespace dynatrace-test-ns deletion
2024-04-29T19:24:29.2304187Z     helper.go:***5: Creating namespace - dynatrace-test-ns
2024-04-29T19:24:29.2308107Z     helper.go:550: Applying template: secretTemplate
2024-04-29T19:24:29.2312194Z     helper.go:550: Applying template: triggerAuthenticationTemplate
2024-04-29T19:24:29.2316268Z     helper.go:550: Applying template: serviceTemplate
2024-04-29T19:24:29.2320314Z     helper.go:550: Applying template: monitoredDeploymentTemplate
2024-04-29T19:24:29.2323148Z     helper.go:550: Applying template: deploymentTemplate
2024-04-29T19:24:29.2325160Z     helper.go:550: Applying template: scaledObjectTemplate
2024-04-29T19:24:29.2327143Z     helper.go:550: Applying template: dynakubeTemplate
2024-04-29T19:24:29.2328861Z     helper.go:564: 
2024-04-29T19:24:29.2330976Z         	Error Trace:	/__w/keda/keda/tests/helper/helper.go:564
2024-04-29T19:24:29.2333355Z         	            				/__w/keda/keda/tests/helper/helper.go:59***
2024-04-29T19:24:29.2335864Z         	            				/__w/keda/keda/tests/scalers/dynatrace/dynatrace_test.go:***46
2024-04-29T19:24:29.2338330Z         	Error:      	Received unexpected error:
2024-04-29T19:24:29.2340662Z         	            	error: error when retrieving current configuration of:
2024-04-29T19:24:29.2343670Z         	            	Resource: "dynatrace.com/v***beta***, Resource=dynakubes", GroupVersionKind: "dynatrace.com/v***beta***, Kind=DynaKube"
2024-04-29T19:24:29.2346580Z         	            	Name: "", Namespace: "default"
2024-04-29T19:24:29.2349146Z         	            	from server for: "/tmp/dynakubeTemplate***6***97***5***": resource name may not be empty
2024-04-29T19:24:29.2351676Z         	Test:       	TestDynatraceScaler
2024-04-29T19:24:29.2354391Z         	Messages:   	cannot apply file - error: error when retrieving current configuration of:
2024-04-29T19:24:29.2357696Z         	            	Resource: "dynatrace.com/v***beta***, Resource=dynakubes", GroupVersionKind: "dynatrace.com/v***beta***, Kind=DynaKube"
2024-04-29T19:24:29.2360534Z         	            	Name: "", Namespace: "default"
2024-04-29T19:24:29.2370269Z         	            	from server for: "/tmp/dynakubeTemplate***6***97***5***": resource name may not be empty
2024-04-29T19:24:29.2373656Z     helper.go:444: Waiting for deployment replicas to hit target. Deployment - dynatrace-test-deployment, Current  - 0, Target - 0
2024-04-29T19:24:29.2376385Z     dynatrace_test.go:***58: --- testing activation ---

JorTurFer avatar Apr 29 '24 19:04 JorTurFer

/run-e2e dynatrace Update: You can check the progress here

JorTurFer avatar Apr 29 '24 19:04 JorTurFer

Same result:

2024-04-29T20:05:14Z	ERROR	dynatrace_scaler	error executing Dynatrace query	{"type": "ScaledObject", "namespace": "dynatrace-test-ns", "name": "dynatrace-test-so", "error": "dynatrace response does not contain any metric series"}

Is this metric correct? "builtin:service.requestCount.total:splitBy():fold"

JorTurFer avatar Apr 29 '24 20:04 JorTurFer

@JorTurFer I am certain the query should return a valid result. Is the host variable still using the .apps sub domain instead of .live as we discussed in the issue? If so, I believe that might indeed be a problem, as testing locally against another Dynatrace instance I have access to, using that URL results in an error, thinking we're trying to use another kind of API: Unsupported authorization scheme 'Api-Token'. Dynatrace platform APIs require the authorization scheme 'Bearer'. Use the OAuth2.0 Client Credentials Flow to obtain a token.

cyrilico avatar May 07 '24 15:05 cyrilico

I've been on a business trip this week, but let me check out your branch and check the current code using the current secrets

JorTurFer avatar May 18 '24 12:05 JorTurFer