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

fix the moving_avg modes #99

Merged
merged 2 commits into from
Mar 21, 2023
Merged

fix the moving_avg modes #99

merged 2 commits into from
Mar 21, 2023

Conversation

gabor
Copy link
Contributor

@gabor gabor commented Feb 21, 2023

(fixes #98)

when using the moving_avg metric, for certain modes there are coefficients (alpha, beta, gamma) that can be configured. the code used parseInt to parse them, so when floating-point values are entered (for example 0.35), it was parsed incorrectly).

also the MovingAverageEWMAModelSettings type was defined incorrectly.

how to test:

  1. make sure you have an opensearch datasource plugin configured ( read https://github.com/grafana/opensearch-datasource/blob/main/devenv/README.md if unsure)
  2. open the opensearch datasource in explore
  3. you should see a working "count" metric query
  4. add another metric, choose moving_avg. configure it:
    • field: choose count
    • in options, choose model=holt-winters
    • set some values, for example:
      • window=5, predict=2, alpha=0.1, beta=0.2, gamma=0.3 (make sure alpha beta and gamma are floating-point values, not integers
  5. make sure the browser-devtools are open
  6. run the query
  7. verify that it did not crash
  8. look at the ajax request (_msearch)'s request-payload, it contains two lines of json, the second json should contain the correct alpha,beta and gamma values.
  9. change the model to exponentially weighted, and repeat the test
  10. change the model to holt linear, and repeat the test
  11. go to dashboards, create a panel, and create the above-mentioned query there. verify it works. save the panel, then reload the page, and verify that the query is persisted correctly, meaning alpha, beta and gamma contain the correct values after a page reload. test all 3 models (holt-winters, holt-linear, exponentially-weighted)

@gabor gabor marked this pull request as ready for review February 22, 2023 13:35
@gabor gabor requested a review from a team as a code owner February 22, 2023 13:35
@gabor gabor requested review from a team, fridgepoet and iwysiu and removed request for a team, fridgepoet and iwysiu February 22, 2023 13:37
Copy link
Contributor

@kevinwcyu kevinwcyu left a comment

Choose a reason for hiding this comment

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

lgtm. saw the values in the json payload as floats.

@kevinwcyu
Copy link
Contributor

Hi @gabor, can this be merged?

@gabor
Copy link
Contributor Author

gabor commented Mar 21, 2023

hi @kevinwcyu , yes, i think it is ready to be merged.

@fridgepoet fridgepoet merged commit c3ea4d8 into main Mar 21, 2023
@fridgepoet fridgepoet deleted the gabor/moving-avg-fix branch March 21, 2023 09:31
@kevinwcyu kevinwcyu mentioned this pull request Mar 23, 2023
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.

Error Unknown key for a VALUE_NUMBER when using EWMA/Holt-Winter with Moving Average
3 participants