Can't authenticate prometheus API

I have triple checked my org slug and token but always get:
something went wrong resolving organization error

curl -X POST “https://api.fly.io/prometheus/$ORG_SLUG/api/v1/query
–data-urlencode ‘query=sum(increase(fly_edge_http_responses_count)) by (app, status)’
-H “Authorization: Bearer $TOKEN”

Trying to set up on grafana cloud and getting 401 and debugging with curl

token seems to be valid

❯ fly tokens debug  $TOKEN
[
  {
    "location": "https://api.fly.io/v1",
    "caveats": [
      {
        "type": "Organization",
        "body": {
          "id": 910942,
          "mask": "rwcdC"
        }
      },
      {
        "type": "3P",
        "body": {
          "Location": "https://api.fly.io/aaa/v1",
...

I ran into this issue very recently, the docs are wrong. Fly is making some changes to how their tokens are created / work, and it seems like something got broken. To fix your issue try removing the "Bearer " portion of your header. Fly tokens now include "FlyV1 " at the start which is the new authorization scheme. Hope this helps!

1 Like

Thanks so much. It tried everything but the obvious and I actually know about authorization headers. cheers!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.