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] ignore_dashboard_filters is not giving any dashboard #232

Closed
paulojmdias opened this issue Dec 14, 2023 · 8 comments
Closed

[BUG] ignore_dashboard_filters is not giving any dashboard #232

paulojmdias opened this issue Dec 14, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@paulojmdias
Copy link

Describe the bug
When we try to set ignore_dashboard_filters: false the gdg is not finding any dashboard. When we set ignore_dashboard_filters: true, he founds everything.

Config

context_name: grafana
storage_engine:
  s3:
    access_id: REDACTED
    bucket_name: grafana
    cloud_type: s3
    custom: "1"
    endpoint: http://localhost:9000
    kind: cloud
    secret_key: REDACTED
    self_hosted: "1"
    ssl_enabled: "0"
contexts:
  grafana:
    storage: s3
    enterprise_support: false
    url: http://localhost:3000
    token: ""
    user_name: REDACTED
    password: REDACTED
    organization_id: 0
    watched_folders_override: []
    watched: []
    connections: null
    datasources: {}
    filter_override:
      ignore_dashboard_filters: false
    output_path: ""
  grafana1:
    storage: s3
    enterprise_support: false
    url: http://localhost:3001
    token: ""
    user_name: REDACTED
    password: REDACTED
    organization_id: 0
    watched_folders_override: []
    watched: []
    connections: null
    datasources: {}
    filter_override:
      ignore_dashboard_filters: false
    output_path: ""
global:
  debug: true
  ignore_ssl_errors: false

To Reproduce

❯ gdg backup dashboards list --skip-confirmation --config config.yml
INFO[0000] Listing dashboards for context: 'grafana'
INFO[0000] No dashboards found

Expected behavior
Even with ignore_dashboard_filters: false the gdg should search on all folders when watched is empty.

Desktop (please complete the following information):

  • GDG Version: 0.5.1
  • Grafana Version: 10.2.2

Additional context
Let me explain better our end goal:

  • We want to backup all dashboards with a specific tag(s) to an S3 bucket
  • We want to sync multiple grafana deployments from this S3 bucket depending on conditions (In this step, we can't filter on upload right?)

Explaining better the upload process:

  • For example, let's imagine the dashboardA has the tags prd and qa, this dashboard should be uploaded in these two environments
  • Let's imagine the dashboardB has the tag prd, this dashboard should be deployed only in prd context, this is possible to be done?
@paulojmdias paulojmdias added the bug Something isn't working label Dec 14, 2023
@safaci2000
Copy link
Contributor

That's intended behavior. You've set watched: [] to an empty list, which is supposed to be the list of folders for GDG to look at, if you give it an empty list then it will look at only General by default. If your dashboards are in ANY other folders it will be ignored.

watched is supposed to be the ONLY folders GDG will operate on, unless you want to ignore all filters by setting the ignore_dashboard_filters.

Also, if you need to back up by a given tag, It may be doable to add that feature, but right now the tag filtering only applies to listing.

  -t, --tags strings        Filter by Tags (does not apply on upload)

@paulojmdias
Copy link
Author

So, to use --tags filter, do we always need to set some folders to watch?

@safaci2000
Copy link
Contributor

safaci2000 commented Dec 14, 2023

So, to use --tags filter, do we always need to set some folders to watch?

Yes, tags would be an additional filter on the folders. So in folder A, B, C we have 7 dashboards and additionally you want to filter out the tags listed. (ie intersection of the two filters ) leaving let's say 3 dashboard that have the tag specified.

If you want to act on a tag across all dashboards, then setting ignore_dashboard_filters: true is the correct behavior.

Also, if you want to add a ticket to support upload by tag, I think that's a fair ask, if you have a use case for it.

You can probably get around it with some shell scripting mixing the listing and -d if you need this urgently but adding support for tag filter on upload would be best.

@paulojmdias
Copy link
Author

I can submit a ticket of course. Just to clarify, we are talking about two features:

  • Add support to --tags when ignore_dashboard_filters: true on download
  • Add support to --tags on upload

Am I right?

@safaci2000
Copy link
Contributor

Yes, the --tags in general isn't really supported properly. So right now the only somewhat supported pattern is on listing.

I don't think the ignore_dashboard_filters flag matters in this case, it's just a matter of respecting the --tags for dashboards. When passed to any operations, which should include download/clear/upload/list it should maintain the behavior.

If you set the ignore_dashboard_filters to true or false it should keep on working as expected.

@safaci2000
Copy link
Contributor

Also, I have noticed you're using "1" for booleans, I haven't really tested that behavior, if that works than that's great but those fields are intended to be booleans.

Also, your OrgId needs to be a valid value, 0 isn't. You'll need to set it to 1 (default Org) or whatever Org you're operating on.

@safaci2000
Copy link
Contributor

Opened up #236 to address this request, closing this ticket.

@safaci2000
Copy link
Contributor

@paulojmdias merged a fix for this request. WIll be part of the next release.

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

2 participants