Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dynatrace scaler #5685

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

cyrilico
Copy link
Contributor

@cyrilico cyrilico commented Apr 11, 2024

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

Checklist

Closes #2411

Relates to kedacore/keda-docs#1360

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: damas <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: damas <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: damas <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: damas <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@cyrilico cyrilico marked this pull request as ready for review April 24, 2024 14:40
@cyrilico cyrilico requested a review from a team as a code owner April 24, 2024 14:40
@zroubalik
Copy link
Member

zroubalik commented Apr 24, 2024

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

@JorTurFer
Copy link
Member

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)

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

tests/scalers/dynatrace/dynatrace_test.go Outdated Show resolved Hide resolved
tests/scalers/dynatrace/dynatrace_test.go Outdated Show resolved Hide resolved
tests/scalers/dynatrace/dynatrace_test.go Outdated Show resolved Hide resolved
cyrilico and others added 2 commits April 28, 2024 14:48
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@cyrilico cyrilico requested a review from JorTurFer April 28, 2024 14:03
@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@cyrilico
Copy link
Contributor Author

new changes, please rerun

@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

@JorTurFer
Copy link
Member

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

pkg/scalers/dynatrace_scaler.go Outdated Show resolved Hide resolved
tests/scalers/dynatrace/dynatrace_test.go Outdated Show resolved Hide resolved
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

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

@JorTurFer
Copy link
Member

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"}

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@cyrilico
Copy link
Contributor Author

cyrilico commented Apr 29, 2024

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 cyrilico requested a review from JorTurFer April 29, 2024 13:27
@JorTurFer
Copy link
Member

JorTurFer commented Apr 29, 2024

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

@JorTurFer
Copy link
Member

JorTurFer commented Apr 29, 2024

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 ---

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented Apr 29, 2024

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

@JorTurFer
Copy link
Member

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"

@cyrilico
Copy link
Contributor Author

cyrilico commented May 7, 2024

@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 cyrilico requested a review from JorTurFer May 9, 2024 09:29
@JorTurFer
Copy link
Member

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

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
@JorTurFer
Copy link
Member

Hello,
I've been testing this locally and I found some things:

  • The dynatrace operator fails because the token doesn't have enough permissions for it
  • The job generators aren't generating the load because the values are overridden
    image

For the dynatrace operator issue, I've created a new secret 'DYNATRACE_OPERATOR_TOKEN', please use it for the operator and the other one for metrics (including for reading them by KEDA)

After making these changes, I see that dynatrace operator has created more pods:
image

But the metric isn't still available:
image

I think that the issue can be in something related with the e2e test configuration because I can see that KEDA is querying the value and getting an empty response with status 200 (so from KEDA side seems that works)
image

@cyrilico
Copy link
Contributor Author

Appreciate the help @JorTurFer 🙏 What metrics are available in that page? The one I used is supposed to be a built-in, i.e., supported OOTB, so I'm curious as to what exactly is available in that dynatrace environment

Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Signed-off-by: cyrilico <19289022+cyrilico@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide scaler for Dynatrace metrics
3 participants