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

[BUG] Unable to retrieve current organization #224

Closed
pinpox opened this issue Nov 14, 2023 · 10 comments
Closed

[BUG] Unable to retrieve current organization #224

pinpox opened this issue Nov 14, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@pinpox
Copy link

pinpox commented Nov 14, 2023

Describe the bug
A clear and concise description of what the bug is. If applicable and possible the JSON of dashboard or datasource that is causing issues with credentials removed would be helpful.

To Reproduce
Steps to reproduce the behavior:

  1. Use this importer.yaml
context_name: prod
storage_engine:
    # any_label:
    #     bucket_name: ""
    #     cloud_type: s3
    #     kind: cloud
    # custom_cloud:
    #     access_id: ""
    #     bucket_name: mybucket
    #     cloud_type: s3
    #     custom: "1"
    #     endpoint: http://localhost:9000
    #     init_bucket: "true"
    #     kind: cloud
    #     prefix: dummy
    #     secret_key: ""
    #     ssl_enabled: "false"
contexts:
    prod:
        storage: ""
        enterprise_support: false
        url: https://prometheus.mydomain.tld/grafana
        token: a service token
        user_name: "admin"
        password: "admin"
        organization_id: 0
        watched_folders_override: []
        watched:
            - General
            - Alerting
            - Gitlab
        connections:
            credential_rules:
                - rules:
                    - field: name
                      regex: .*
                  auth:
                    user: admin
                    password: admin
        datasources: {}
        filter_override: null
        output_path: exports
global:
    debug: true
    ignore_ssl_errors: false
  1. Run gdg backup connections download, it fails with the error:
Unable to retrieve current organization, err: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 404): {}

https://prometheus.mydomain.tld/grafana is the url where I can view grafana in the browser.

Expected behavior
Dashboards are downloaded

Desktop (please complete the following information):
Build Date:
Git Commit:
Version: 0.5.1
Go Version: go1.21.3
OS / Arch: linux amd64

Additional context
I verified the token is working, the following curl works fine:

 curl 'https://prometheus.mydomain.tld/grafana/api/org' -H 'Authorization: Bearer **********************************'

It returns json with an organisation

@pinpox pinpox added the bug Something isn't working label Nov 14, 2023
@safaci2000
Copy link
Contributor

The only thing I would change, is the org ID. Unless you have a valid org with that ID, if you using the grafana admin you can view the Orgs using:

./bin/gdg backup orgs list
2023-11-14 11:54:18 INF backup/organizations.go:45 Listing organizations for context context=testing
┌────┬───────────┐
│ ID │ ORG       │
├────┼───────────┤
│  1 │ Main Org. │
└────┴───────────┘

"Main Org." is the default from an untouched configuration. I'll try to make this behavior a bit more intuitive, adding org support has been a more recent change and usability patterns are still being worked out.

@safaci2000
Copy link
Contributor

I'll close this out, if you still have issues or any questions feel free to re-open it.

@NicoJDE
Copy link

NicoJDE commented Dec 27, 2023

There is still a problem. I have the same config as @pinpox
The problem is that the client makes a call to

prometheus.int.gg.de 10.0.8.11 - - [27/Dec/2023:10:33:57 +0000] 1700 "GET /api/user HTTP/1.1" 404 196 "-" "Go-http-client/1.1"
prometheus.int.gg.de 10.0.8.11 - - [27/Dec/2023:10:33:57 +0000] 1054 "GET /api/org HTTP/1.1" 404 196 "-" "Go-http-client/1.1"

With curl

prometheus.int.gg.de 10.0.8.11 - - [27/Dec/2023:10:28:45 +0000] 13216 "GET /grafana/api/org HTTP/1.1" 200 126 "-" "curl/8.4.0"

@NicoJDE
Copy link

NicoJDE commented Dec 27, 2023

@safaci2000

@esnet esnet deleted a comment from csg33k Dec 27, 2023
@safaci2000
Copy link
Contributor

What version of grafana are you using?

I'm assuming you're seeing the org id to a non zero value?

@NicoJDE
Copy link

NicoJDE commented Dec 28, 2023

The problem is not the Org ID.
The actual problem is that the client makes a call to /api/org but the call should go to /grafana/api/org

@safaci2000
Copy link
Contributor

Well,

gdg version
Build Date: 2023-11-03T17:31:01Z
Git Commit: 6b7b922c441bc0f6f928c042b69daee547db9d32
Version: v0.5.1
Go Version: go1.21.3
OS / Arch: darwin arm64

(I just reinstalled the latest version using brew )

config:

context_name: testing

contexts:
  testing:
    output_path: test/data
    enterprise_support: true
    url: http://localhost:3000
#   user_name: admin
#   password: admin
    token: glsa_lzHTC8EwbRwhSuKTbIGNzVPgQ5wkRXBQ_5fefcbd0
    filter_override:
      ignore_dashboard_filters: false # When set to true all Watched filtered folders will be ignored and ALL folders will be acted on
    watched:
      - General
      - Other

global:
  debug: true
  ignore_ssl_errors: false 

Uploading dashboards, listing dashboards, all of that worked fine.

gdg b dash list                                                                                                                                  (docker-desktop/default)
INFO[0000] Listing dashboards for context: 'testing'    
┌────┬──────────────────────────────┬──────────────────────────────┬─────────┬───────────┬──────────────┬────────────────────────────────────────────────────────────────┐
│ ID │ TITLE                        │ SLUG                         │ FOLDER  │ UID       │ TAGS         │ URL                                                            │
├────┼──────────────────────────────┼──────────────────────────────┼─────────┼───────────┼──────────────┼────────────────────────────────────────────────────────────────┤
│  1 │ Bandwidth Dashboard          │ bandwidth-dashboard          │ General │ 000000003 │ netsage      │ http://localhost:3000/d/000000003/bandwidth-dashboard          │
│  2 │ Bandwidth Patterns           │ bandwidth-patterns           │ General │ 000000004 │ netsage      │ http://localhost:3000/d/000000004/bandwidth-patterns           │
│ 10 │ Dashboard Makeover Challenge │ dashboard-makeover-challenge │ Other   │ F3eInwQ7z │              │ http://localhost:3000/d/F3eInwQ7z/dashboard-makeover-challenge │
│ 11 │ Flow Analysis                │ flow-analysis                │ Other   │ VuuXrnPWz │ flow,netsage │ http://localhost:3000/d/VuuXrnPWz/flow-analysis                │
│ 12 │ Flow Data for Circuits       │ flow-data-for-circuits       │ Other   │ xk26IFhmk │ flow,netsage │ http://localhost:3000/d/xk26IFhmk/flow-data-for-circuits       │
│ 13 │ Flow Data for Projects       │ flow-data-for-projects       │ Other   │ ie7TeomGz │              │ http://localhost:3000/d/ie7TeomGz/flow-data-for-projects       │
│ 14 │ Flow Data per Country        │ flow-data-per-country        │ Other   │ fgrOzz_mk │ flow,netsage │ http://localhost:3000/d/fgrOzz_mk/flow-data-per-country        │
│ 15 │ Flow Data per Organization   │ flow-data-per-organization   │ Other   │ QfzDJKhik │ flow,netsage │ http://localhost:3000/d/QfzDJKhik/flow-data-per-organization   │
│ 16 │ Flow Information             │ flow-information             │ Other   │ nzuMyBcGk │              │ http://localhost:3000/d/nzuMyBcGk/flow-information             │
│ 17 │ Flows by Science Discipline  │ flows-by-science-discipline  │ Other   │ WNn1qyaiz │ flow,netsage │ http://localhost:3000/d/WNn1qyaiz/flows-by-science-discipline  │
│  4 │ Individual Flows             │ individual-flows             │ General │ -l3_u8nWk │ netsage      │ http://localhost:3000/d/-l3_u8nWk/individual-flows             │
│  3 │ Individual Flows per Country │ individual-flows-per-country │ General │ 80IVUboZk │ netsage      │ http://localhost:3000/d/80IVUboZk/individual-flows-per-country │
│  5 │ Loss Patterns                │ loss-patterns                │ General │ 000000006 │ netsage      │ http://localhost:3000/d/000000006/loss-patterns                │
│  6 │ Other Flow Stats             │ other-flow-stats             │ General │ CJC1FFhmz │ flow,netsage │ http://localhost:3000/d/CJC1FFhmz/other-flow-stats             │
│  7 │ Science Discipline Patterns  │ science-discipline-patterns  │ General │ ufIS9W7Zk │ flow,netsage │ http://localhost:3000/d/ufIS9W7Zk/science-discipline-patterns  │
│  8 │ Top Talkers Over Time        │ top-talkers-over-time        │ General │ b35BWxAZz │              │ http://localhost:3000/d/b35BWxAZz/top-talkers-over-time        │
└────┴──────────────────────────────┴──────────────────────────────┴─────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────────┘

So, once again, what version of grafana are you using, gdg version, operating system etc...

@safaci2000 safaci2000 reopened this Dec 28, 2023
@NicoJDE
Copy link

NicoJDE commented Dec 28, 2023

gdg version

Build Date: 2023-11-03T17:31:01Z
Git Commit: 6b7b922c441bc0f6f928c042b69daee547db9d32
Version: v0.5.1
Go Version: go1.21.3
OS / Arch: darwin arm64

Config:

context_name: prod
storage_engine:
  any_label:
    bucket_name: ""
    cloud_type: s3
    kind: cloud
  custom_cloud:
    access_id: ""
    bucket_name: mybucket
    cloud_type: s3
    custom: "1"
    endpoint: http://localhost:9000
    init_bucket: "true"
    kind: cloud
    prefix: dummy
    secret_key: ""
    ssl_enabled: "false"
contexts:
  prod:
    storage: ""
    enterprise_support: false
    url: "https://prometheus.int.somedomain.de/grafana/"
    token: "secret_token"
    # user_name: "admin"
    # password: "admin"
    organization_id: 1
    watched_folders_override: []
    watched:
      - Gitlab
    datasources: {}
    filter_override:
      ignore_dashboard_filters: true
    output_path: ""
global:
  debug: true
  ignore_ssl_errors: false

grafana_version: 10.2.2

Grafana is in my setup behind a reverse proxy. The web url ist sometld.de/grafana in your example you use sometld.de

Curl on Grafana works:

curl 'https://sometld.de/grafana/api/org/' -H 'Authorization: Bearer glsa_Nab88-securetoken'
{"id":1,"name"some name","address":{"address1":"","address2":"","city":"","zipCode":"","state":"","country":""}}%

Error:

gdg b dash list
FATA[0000] Failed to retrieve dashboardsresponse status code does not match any response statuses defined for this endpoint in the swagger spec (status 404): {}

safaci2000 added a commit that referenced this issue Dec 28, 2023
Addresses latter part of #224
@safaci2000
Copy link
Contributor

This was an issue with the URI path, I'll see about adding some test to avoid this in the future, but #235 should fix your concern.

safaci2000 added a commit that referenced this issue Jan 3, 2024
* Fixing bug with reverse proxy path

Addresses latter part of #224 and #233 

* adding a test for the URI Bug

* Migrating to New API Pattern

* Re-Adding Grafana Proxy test

* Addressing code review comments.
@safaci2000
Copy link
Contributor

Fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants