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

Fetch Grafana version from /api/frontend/settings #144

Conversation

squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Sep 28, 2024

AMG API doesn't contain /api/health endpoint, which makes it impossible to use grafana-wtf with this kind of setup.

The proposal is to use /api/frontend/settings for the same purpose, which works for both regular and AWS-managed Grafana versions.

Fixes #141

@squadgazzz squadgazzz force-pushed the support-aws-managed-grafana-version-fetching branch 2 times, most recently from 11fffe5 to e8f243b Compare September 28, 2024 10:32
if not isinstance(response, dict):
error = f"{error_template}: Invalid response, content was: {response}"

response = Munch(response)
response = response.get("buildInfo")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole response is quite large. It makes sense to return only basic buildInfo which contains similar to /api/health response data.

@squadgazzz squadgazzz force-pushed the support-aws-managed-grafana-version-fetching branch from e8f243b to 1b9ef80 Compare September 28, 2024 10:34
health = wtf.health
assert "commit" in health
assert "version" in health
assert health.database == "ok"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

database status is not represented in the buildInfo response.

@squadgazzz squadgazzz changed the title Fetch version from /api/frontend/settings Fetch Grafana version from /api/frontend/settings Sep 28, 2024
Copy link

codecov bot commented Sep 28, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.15%. Comparing base (a5db83e) to head (7be7d22).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
grafana_wtf/core.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
- Coverage   87.21%   87.15%   -0.06%     
==========================================
  Files           9        9              
  Lines        1079     1082       +3     
==========================================
+ Hits          941      943       +2     
- Misses        138      139       +1     
Flag Coverage Δ
unittests 87.15% <88.88%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@amotl amotl left a comment

Choose a reason for hiding this comment

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

Thanks a stack!

@amotl amotl merged commit 9153a57 into grafana-toolbox:main Sep 28, 2024
16 checks passed
@amotl
Copy link
Contributor

amotl commented Sep 28, 2024

Your improvement has been included into version 0.20.0, just released. Thanks again.

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.

Support AWS managed API
2 participants