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

Top() function returns incorrect set of series #1313

Closed
alexanderzobnin opened this issue Sep 23, 2021 · 1 comment
Closed

Top() function returns incorrect set of series #1313

alexanderzobnin opened this issue Sep 23, 2021 · 1 comment

Comments

@alexanderzobnin
Copy link
Collaborator

Describe the bug
top() function returns wrong set of series.

Screenshots
Original set:
Screenshot from 2021-09-23 17-26-33

Returned by top(5, max):
Screenshot from 2021-09-23 17-26-42

Software versions

Grafana Zabbix Grafana-Zabbix Plugin
x.x.x x.x.x 4.2.3
@alexanderzobnin alexanderzobnin added this to the 4.2.4 milestone Sep 23, 2021
@alexanderzobnin alexanderzobnin changed the title Top() function returns incorrect series Top() function returns incorrect set of series Sep 23, 2021
@alexanderzobnin
Copy link
Collaborator Author

This bug happens because of wrong custom sorting implementation here:
https://github.com/alexanderzobnin/grafana-zabbix/blob/750292296c1fcff7082b09747614fe66b3077961/pkg/timeseries/sort.go#L16-L19

In this case another slice (aggregatedSeries) is using for comparing values, but the Swap() function changes the original series slice, so algorithm does not work as expected. So the solution is either use series in comparison or fully implement sort interface (Len/Less/Swap methods).

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

No branches or pull requests

1 participant