grafana-toolbox / grafana-wtf

Grep through all Grafana entities in the spirit of git-wtf.
GNU Affero General Public License v3.0
156 stars 16 forks source link

Support AWS managed API #141

Closed squadgazzz closed 1 month ago

squadgazzz commented 3 months ago

Seems like AWS-managed Grafana API doesn't support the whole Grafana API(at least /api/health)

amotl commented 1 month ago

Dear @squadgazzz,

thanks for the report. Does that mean it causes any errors when using grafana-wtf on AMG?

With kind regards, Andreas.

/cc @bhks

squadgazzz commented 1 month ago

thanks for the report. Does that mean it causes any errors when using grafana-wtf on AMG?

@amotl, yes. grafana-wtf tries to call /api/health endpoint, which doesn't exist in AWS managed Grafana API. I didn't investigate further what could fail next since the app failed on the health step.

bhks commented 1 month ago

Hi squadgazzz,

Are you using any network restriction on your workspace from AWS Managed grafana ?

I don't think this would be any problem with this project, you can just test with a simple server of grafana to see if the health check is working or not if its working then it should not be problem.

If I rem correctly Amazon Managed grafana might have disabled the health check as public endpoint path.

Regards Bhagwat

bhks commented 1 month ago

I just tested and /healthz is allowed but not the /api/health one.

amotl commented 1 month ago

Hi. Thanks for your valuable responses. Currently, I think inquiring the /api/health endpoint is (mostly?) to get hold of the Grafana version on the server side.

https://github.com/grafana-toolbox/grafana-wtf/blob/a5db83eb5bdac2801994cf652a6a739a903bb19e/grafana_wtf/core.py#L343-L345

https://github.com/grafana-toolbox/grafana-wtf/blob/a5db83eb5bdac2801994cf652a6a739a903bb19e/grafana_wtf/core.py#L323-L341

So, to improve the situation for AMG users, may I ask you for a bit more of your support? That would be so sweet!

a) Will version inquiry also work on the /healthz endpoint? b) Can you share any documentation or other resources about the /healthz endpoint? I haven't been able to discover anything valuable on a very quick web search.

If version inquiry is not possible with AMG (is it?), do you suggest any other workarounds? Our idea would be to always assume most recent Grafana in this case, but let the user override it manually, when it can not be inquired automatically.

squadgazzz commented 1 month ago

a) Will version inquiry also work on the /healthz endpoint?

This endpoint returns a simple 200OK.

There is the /api/frontend/settings endpoint, which returns a lot of the data, including all the versions, etc. Looks like AWS's version is the same as the Grafana API states: https://grafana.com/docs/grafana/latest/developers/http_api/other/#get-settings

Location in the json is simply buildInfo -> version.

I prepared a PR for this.

bhks commented 1 month ago

Yes that /api/frontend/settings API is the right place and also the AWS API for Grafana.

amotl commented 1 month ago

Thank you both for your excellent support. @squadgazzz's patch has been merged, and the improvement is included in version 0.20.0, now on PyPI.

-- https://github.com/grafana-toolbox/grafana-wtf/releases/tag/0.20.0