Grafana dashboard: Grafana Reports
Description: This dashboard contains a panel that allows you to faster generate reports from dashboards.

## Getting started

Requirements:

    apt install golang-go
    apt install texlive-latex-base   
  
Get the source files and dependencies:

    go get github.com/IzakMarais/reporter/...
Build and install grafana-reporter binary:

    go install -v github.com/IzakMarais/reporter/cmd/grafana-reporter
Running without any flags assumes Grafana is reachable at localhost:3000:
    
    export GOPATH=$HOME/go
    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
    grafana-reporter

## Credits
All thanks goes to [IzakMarais](https://github.com/IzakMarais) who made the Service that generates a PDF report from a Grafana dashboard.

For more info browse his github [Repository](https://github.com/IzakMarais/reporter).



## About This Panel
This panel allows you to faster generate reports from dashboards and make the use of [IzakMarais](https://github.com/IzakMarais) work to be easily manipulated here by using its API.

For customizable dashboards and functionalities [Contact me](mailto:khalil.mejdi97@gmail.com).

And yes, do not forget to review.

### TODO 
* [X] Get Folder.
* [X] Get Dashboard.
* [X] Generate reports.
* [O] Manipule variables.
* [O] Select time.
* [O] Ability to direct download.

[![](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bujupah)

{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.3.3"
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 11365,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "content": "\n## Getting started\nRequirements:\n\n    apt install golang-go\n    apt install texlive-latex-base   \n  \nGet the source files and dependencies:\n\n    go get github.com/IzakMarais/reporter/...\nBuild and install grafana-reporter binary:\n\n    go install -v github.com/IzakMarais/reporter/cmd/grafana-reporter\nRunning without any flags assumes Grafana is reachable at localhost:3000:\n    \n    export GOPATH=$HOME/go\n    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin\n    grafana-reporter\n\n## Credits\nAll thanks goes to [IzakMarais](https://github.com/IzakMarais) who made the Service that generates a PDF report from a Grafana dashboard <br>\nFor more info browse his github [Repository](https://github.com/IzakMarais/reporter)<br>\n\n\n## About This Panel\nThis panel allows you to faster generate reports from dashboards and make the use of [IzakMarais](https://github.com/IzakMarais) work to be easily manipulated here.\n\nFor customizable dashboards and functionalities [Contact me](mailto:khalil.mejdi97@gmail.com)\n",
      "gridPos": {
        "h": 22,
        "w": 9,
        "x": 0,
        "y": 0
      },
      "id": 4,
      "mode": "markdown",
      "options": {},
      "timeFrom": null,
      "timeShift": null,
      "title": "How to install Grafana-Report",
      "transparent": true,
      "type": "text"
    },
    {
      "content": "<script>\n\nvar port = 8686; //DEFAULT\nvar host = window.location.host.split(':')[0]; //DEFAULT\nvar token = \"eyJrIjoiQjhTTTVPNTBOWTdWN3ZDbFVPbjVCMllKMDFkazZldUgiLCJuIjoidGVzdCIsImlkIjoxfQ==\";\n\n</script>\n\n<div class=\"text-center\">\n  <select style=\"height: auto;\" id=\"dashFolders\" class=\"btn btn-primary\"></select> \n  <select style=\"height: auto;\" id=\"dashUID\" class=\"btn btn-primary\"></select>\n  <button style=\"height: auto;\" id=\"generateBtn\" class=\"btn btn-primary\"><i class=\"fa fa-fw fa-file-text-o\"></i> Generate Report </button>\n</div>\n\n<script>\n\n$(document).ready(function(){\n  init();\n  getFolders();\n  $(\"#dashFolders\").change(function(){\n    $(\"#dashUID\").children('option:not(:first)').remove();\n    getDashboards($(\"#dashFolders\").val());\n  });\n});\n\nfunction init(){\n  $('#dashFolders').append(\"<option class='gf-form'> <span> <i class='fa fa-fw fa-th-large'> Select Folder </span> </option>\");\n  $('#dashUID').append(\"<option class='gf-form'> Select Dashboard </option>\");\n  $(\"#dashUID\").children('option:not(:first)').remove();\n}\n\nfunction getFolders(){ \n  $.ajax({\n    type: 'GET',\n    url: '/api/search',\n    data: 'query=&type=dash-folder',\n    dataType: 'json',\n    async: false,\n    success: function (data) {\n      $.each(data, function(index, el) {\n        $('#dashFolders').append(\"<option class='gf-form' value=\"+el.id+\">\"+el.title+\"</option>\");\n      });\n    }\n  }); \n}\n\nfunction getDashboards(id){\n  $.ajax({\n    type: 'GET',\n    url: '/api/search',\n    data: 'folderIds='+id+'&query=',\n    dataType: 'json',\n    async: false,\n    success: function (data) {\n      $.each(data, function(index, el) {\n        $('#dashUID').append(\"<option class='gf-form' value=\"+el.uid+\">\"+el.title+\"</option>\");\n      });\n    }\n  });\n}\n\n$(\"#generateBtn\").click(function(){\n  generate();\n});\n\nfunction generate(){\n  var uid = $(\"#dashUID\").val();\n  var url = \"http://\"+host+\":\"+port+\"/api/v5/report/\"+uid+\"?apitoken=\"+token;\n  window.open(url, '_blank',\"width=600,height=400\"); \n}\n\n\n</script>\n ",
      "gridPos": {
        "h": 3,
        "w": 12,
        "x": 11,
        "y": 0
      },
      "id": 2,
      "mode": "html",
      "options": {},
      "timeFrom": null,
      "timeShift": null,
      "title": "Generate Reports from dashboards",
      "type": "text"
    }
  ],
  "schemaVersion": 19,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Grafana Reports",
  "uid": "9NY3v0aZk",
  "version": 9,
  "description": "This dashboard contains a panel that allows you to faster generate reports from dashboards."
}