anryko / grafana-influx-dashboard

Grafana InfluxDB scripted dashboard
MIT License
132 stars 44 forks source link

Update method to have getdash show up on grafana main page #54

Closed lawre closed 8 years ago

lawre commented 8 years ago

Previously there were instructions to modify grafana 2.x's app.js files:

sed -i 's|\({text:\"Dashboards\",icon:\"fa fa-fw fa-th-large\",href:a.getUrl(\"/\")}\)|\1,{text:\"GetDash\",icon:\"fa fa-fw fa-th-large\",href:a.getUrl(\"/dashboard/script/getdash.js\")}|' /usr/share/grafana/public/app/app.*js

This no longer works. Please provide a new method for integrating getdash with the main grafana 3.x page. Thanks!

anryko commented 8 years ago

Hi lawre, Now it is more complicated to change grafana 3 menu. However, I found IMO better solution with adding redirect dashboard. Unfortunately I can't just give you the dashboard JSON to import because grafana will automatically execute it and perform the redirect. So there will be no way for you to save imported dashboard. Nevertheless I'll do my best trying to explain how to do that manually, using grafana GUI.

You will have to create a new grafana dashboard. In dashboard settings you should rename it to "Scripted Dashboard". Then add a "text" row of "html" type. Then to the text field of that row you need paste this code:

<meta http-equiv="refresh" content="1;url=/dashboard/script/getdash.js">
<script type="text/javascript">window.location.href = "/dashboard/script/getdash.js"</script>

After this is done you will have to save the dashboard. That's it. Now from your Grafana Home screen you can select newly created "Scripted Dashboard" and it will automatically redirect you to the actual GetDash dashboard.

Here is exported dashboard. Just in case I failed in my explanation and maybe JSON code will be clearer :). You will not be able to import it but maybe it will help.

{
  "id": 2,
  "title": "Scripted Dashboard",
  "tags": [],
  "style": "dark",
  "timezone": "browser",
  "editable": true,
  "hideControls": true,
  "sharedCrosshair": false,
  "rows": [
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "title": "Scripted Dashboard automatic redirect",
          "error": false,
          "span": 12,
          "editable": true,
          "type": "text",
          "isNew": true,
          "id": 1,
          "mode": "html",
          "content": "<meta http-equiv=\"refresh\" content=\"1;url=/dashboard/script/getdash.js\">\n<script type=\"text/javascript\">window.location.href = \"/dashboard/script/getdash.js\"</script>",
          "links": [],
          "height": "20px",
          "transparent": true
        }
      ],
      "title": "Row"
    }
  ],
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "templating": {
    "list": []
  },
  "annotations": {
    "list": []
  },
  "schemaVersion": 12,
  "version": 0,
  "links": []
}
lawre commented 8 years ago

I tested your method and it works better than the method before. I had no idea an html refresh/redirect would work, so I hope this is an intended feature and the grafana team won't "fix" it in the future. :)

anryko commented 8 years ago

I hope so too :).

lawre commented 8 years ago

one issue i found: once the redirect is created, it is impossible to edit it through the UI since it gets redirected away. Any suggestions?

anryko commented 8 years ago

Create a new one with the same name. Then on saving action it will let you overwrite the old one.

vasekch commented 7 years ago

Another downside is that you can't use such dashboards in playlists, such a pity. Nice workaround, though.