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

Transformations: Add regression analysis transformation #78457

Merged
merged 15 commits into from Nov 24, 2023

Conversation

oscarkilhed
Copy link
Contributor

@oscarkilhed oscarkilhed commented Nov 21, 2023

What is this feature?

This adds a transformation that fits a mathematical function to X/Y data.

Typically this can be used on time series to get a trend line.

regression

Which issue(s) does this PR fix?:

Fixes #7812
Fixes #73441

Special notes for your reviewer:

Todo:

  • Add tests.
  • Add descriptive image.
  • Figure out a name for the transformation.
  • Docs.

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@oscarkilhed oscarkilhed requested a review from a team as a code owner November 21, 2023 12:27
@oscarkilhed oscarkilhed added this to the 10.3.x milestone Nov 21, 2023
@grafana grafana deleted a comment from ephemeral-instances-bot bot Nov 21, 2023
@grafana grafana deleted a comment from ephemeral-instances-bot bot Nov 21, 2023
@oscarkilhed
Copy link
Contributor Author

/deploy-to-hg

@ephemeral-instances-bot
Copy link

  • Preparing your instance. A comment containing your instance's url will be added to this PR when the instance is ready.
  • Your instance will be ready in ~10 minutes.
  • Check the GitHub actions tab to follow the workflow progress
  • Slack channel: #proj-ephemeral-hg-instances
  • Building instance with oscark/regression-transformation oss branch and main enterprise branch. How to choose a branch

Copy link
Contributor

@baldm0mma baldm0mma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible issue with Data frames...

Copy link
Collaborator

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! I've left one question which should be resolved before you merge, but otherwise, this looks fine to me.

'Polynomial regression'
)}

> **Note:** This mode is an experimental feature. Engineering and on-call support is not available. Documentation is either limited or not provided outside of code comments. No SLA is provided. Enable the \`regressionTransformation\` feature toggle in Grafana to use this feature. Contact Grafana Support to enable this feature in Grafana Cloud.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you referring to when you use the word "mode" here? The two models above or the whole Regression analysis transformation? If the former, then we should use "model"; if the latter then we should use "transformation". It's not clear what you mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you. This refers the the transformation as a whole. Have changed the note to reflect that.

@oscarkilhed oscarkilhed requested a review from a team as a code owner November 24, 2023 08:00
@oscarkilhed oscarkilhed requested review from tskarhed and JoaoSilvaGrafana and removed request for a team November 24, 2023 08:00
@baldm0mma
Copy link
Contributor

Screenshot 2023-11-24 at 7 31 22 AM

Go home git, you're drunk.

@oscarkilhed
Copy link
Contributor Author

Screenshot 2023-11-24 at 7 31 22 AM Go home git, you're drunk.

I believe this is the commit hook auto formatting spaces to tabs

@oscarkilhed oscarkilhed merged commit ab982e7 into main Nov 24, 2023
25 checks passed
@oscarkilhed oscarkilhed deleted the oscark/regression-transformation branch November 24, 2023 14:49
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
@3ricj
Copy link

3ricj commented Jan 25, 2024

I'm really excited about this feature -- it seems to be included in 10.3, which is what I just updated to. However, I seem unable to find how to use it or turn it on or enable it. I've been looking for documentation to assist, without any luck so far. Help?

@whizkidTRW
Copy link

Same here! Following for updates.

@mcpherrinm
Copy link

The documentation is in the PR you're commenting on, and visible at https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#regression-analysis

Notably, you'll need to turn a feature toggle on.

@whizkidTRW
Copy link

Ah, excellent! The only thing I see now is that in my implementation, I have network graphs where there's an In data rate and an Out data rate (Negative-Y) and I'd like to show a trendline for both. Is there any way to name both regressions uniquely?

I tried adding two regressions and set them both to Polynomial (which works perfectly!) but the Organize fields by name transformation only sees one field instead of two since they're named the same. Can it derive from the Y field possibly?

image

@oscarkilhed
Copy link
Contributor Author

oscarkilhed commented Jan 25, 2024

@whizkidTRW Hmm, it should be named after the y field: https://github.com/grafana/grafana/blob/main/public/app/features/transformers/regression/regression.ts#L111

Not sure why yours are named value. Open an issue and follow the guide on how to attach the panel data and I can take a look.

@whizkidTRW
Copy link

whizkidTRW commented Jan 25, 2024

Done! #81317

Let me know if you need more data or examples, I'm happy to share as I really look forward to using this feature.

Thanks!

@oscarkilhed
Copy link
Contributor Author

Should be fixed with this PR: #81332

@whizkidTRW
Copy link

Excellent. Thank you! I look forward to trying this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time series: Add trend line / regression line [Feature request] draw trend line
8 participants