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

panels of type gauge and bar gauge lose their settings #99

Closed
itewk opened this issue Dec 20, 2019 · 9 comments
Closed

panels of type gauge and bar gauge lose their settings #99

itewk opened this issue Dec 20, 2019 · 9 comments

Comments

@itewk
Copy link
Contributor

itewk commented Dec 20, 2019

When I try to import dashboards via the CR with panels of type guage or bar gauge the settings for those pannels get lost.

I have tried using the json and the url form of the GrafanaDashboard type. both have same experince.

I can copy the exact same JSON direclty into the same Grafana dashboard import feature and the panels import fine. This only seems to happen when the board gets imported via the Operator and I can't for the life of me figure out what is causing it. I can only assume at this point since I can copy paste directly in that the operator has to be doing something or importing the board in such a way that something somewhere is going funky.

@itewk
Copy link
Contributor Author

itewk commented Dec 20, 2019

example dashboard I can reproduce with

{
  "__inputs": [
    {
      "name": "DS_OPENSHIFT_PROMETHEUS",
      "label": "openshift-prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.5.2"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1576850855482,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_OPENSHIFT_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "defaults": {
            "links": [],
            "mappings": [
              {
                "from": "",
                "id": 1,
                "operator": "",
                "text": "",
                "to": "",
                "type": 1,
                "value": ""
              }
            ],
            "max": 1,
            "min": 0,
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 0.85
              }
            ],
            "title": "",
            "unit": "percentunit"
          },
          "override": {},
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": false
      },
      "pluginVersion": "6.5.2",
      "targets": [
        {
          "expr": "(sum by (hostname) ( heketi_device_used_bytes {job = \"$job\"} )) / (sum by (hostname) ( heketi_device_size_bytes {job = \"$job\"} ))",
          "format": "time_series",
          "instant": false,
          "intervalFactor": 1,
          "legendFormat": "{{hostname}}",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Storage Devices Capacity Used",
      "type": "gauge"
    }
  ],
  "schemaVersion": 21,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "text": "openshift-prometheus",
          "value": "openshift-prometheus"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Datasource",
        "multi": false,
        "name": "DS_OPENSHIFT_PROMETHEUS",
        "options": [],
        "query": "prometheus",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$DS_OPENSHIFT_PROMETHEUS",
        "definition": "label_values(heketi_up,job)",
        "hide": 0,
        "includeAll": false,
        "label": "Job",
        "multi": false,
        "name": "job",
        "options": [],
        "query": "label_values(heketi_up,job)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "TEST"
}

@pb82
Copy link
Collaborator

pb82 commented Dec 22, 2019

I'm assuming it has to do with the grafana-sdk library that we use to parse the dashboard json. I'll investigate further.

@itewk
Copy link
Contributor Author

itewk commented Dec 23, 2019

Yeah. I tried to trace through the operator code to see how dashboard gets imported to see if I could isolate to whether it was something operator was doing or Grafana but I lost the thread when it called the grafana sdk.

@pb82
Copy link
Collaborator

pb82 commented Dec 23, 2019

@itewk The problem lies somewhere with the grafana sdk. I'm currently working on removing it and just sending the raw json (after some validation). That seems to be working and the gauge in your example renders exactly the same operator imported vs. directly imported.

@pb82
Copy link
Collaborator

pb82 commented Dec 23, 2019

@itewk This should be fixed now in this PR: #95 I've created a tag with those change import-datasources: https://quay.io/repository/integreatly/grafana-operator?tab=tags

Would you mind giving it a try?

Please note that since your dashboard has inputs (depends on a datasource to be present) you will have to specify it in the dashboard CR with:

spec:
  datasources:
    inputName: "DS_OPENSHIFT_PROMETHEUS"
    datasourceName: <name of the corresponding datasource in your instance>

Docs for this are in the works: https://github.com/integr8ly/grafana-operator/pull/95/files#diff-87206ddedd4460f8733d5d3074b725adR90

@itewk
Copy link
Contributor Author

itewk commented Dec 26, 2019

@pb82 tested the import-datasources image tag and it works great, fixes this issue. Thank you.

@yogeek
Copy link

yogeek commented Jan 2, 2020

@pb82 I also confirm that the import-datasources image tag resolves problems that were caused by the use of the grafana sdk.
Do you know when this version will be released please ? (github release and latest image tag)
By the way, when is the latest image tag pushed in your release workflow ?

@pb82
Copy link
Collaborator

pb82 commented Jan 3, 2020

@yogeek I'll aim for a release around the 10th of January. Unfortunately there is currently no automation for creating the latest tag. Travis currently only creates tags for releases and branches. That's probably something we should automate. I'll update latest manually today.

@pb82
Copy link
Collaborator

pb82 commented Jan 3, 2020

The latest tag is up to date with master now.

@pb82 pb82 closed this as completed Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants