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

Allow providing dashboard's JSON in base64 gzipped format #1338

Closed
iRevive opened this issue Feb 8, 2024 · 1 comment
Closed

Allow providing dashboard's JSON in base64 gzipped format #1338

iRevive opened this issue Feb 8, 2024 · 1 comment

Comments

@iRevive
Copy link

iRevive commented Feb 8, 2024

Hello!

I’m developing a provider that allows describing Grafana dashboards using HCL.

For example:

# Define Grafana provider
provider "grafana" {
  url  = "https://grafana.example.com/"
  auth = var.grafana_auth
}

# Create your dashboard
resource "grafana_dashboard" "my_dashboard" {
  config_json = data.gdashboard_dashboard.dashboard.json # the JSON representation of the dashboard
}

data "gdashboard_dashboard" "dashboard" {
  title = "My dashboard"

  layout {
    section {
      title = "Basic Details"

      panel {
        size = {
          height = 8
          width  = 10
        }
        source = data.gdashboard_stat.status.json
      }
    }
  }
}

data "gdashboard_stat" "status" {
  title       = "Status"
  description = "Shows the status of the container"

  field {
    mappings {
      value {
        value        = "1"
        display_text = "UP"
        color        = "green"
      }

      special {
        match        = "null+nan"
        display_text = "DOWN"
        color        = "red"
      }
    }
  }

  queries {
    prometheus {
      uid     = "prometheus"
      expr    = "up{container_name='container'}"
      instant = true
    }
  }
}

Unfortunately, the JSON output may become rather big when managing dashboards with many panels. As a result, the state file will grow, too. For example, 20+ dashboards with 20-30 panels each can easily occupy 20 MBs of the state file.

If the state file is stored in remote storage (e.g. S3), it takes 30-90 seconds only to download the file, which makes updates notably slow.

To keep the state file compact, I would like to keep the JSON representation gzipped and base64 encoded.

Since base64gunzip does not exist in the terraform (Feature request: gunzip function · Issue #22568 · hashicorp/terraform · GitHub), the stored content needs to be decoded by the Grafana plugin.


Would it be feasible to add a new config_json_base64_gzip (or any other suitable name) property to the dashboard resource? If so, I can work on the implementation.

@julienduchesne
Copy link
Member

I'll close this one in favor of #1288. The goal is the same: reducing the amount of json that goes into the state. If something were to be implemented, it'd be a similar solution

@julienduchesne julienduchesne closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants