Grafana dashboard: Internal Grafana Stats (Elasticsearch)
Description: Data Proxy request timings (percentiles), dashboard loads, logins etc, Elasticsearch version. 

Modified version of the original (graphite) to work with Elasticsearch.

The below powershell script, will collect the metrics from the grafana API based on the interval set and publish the data to Elasticsearch.

Update:

    [string[]]$grafanaServers = "localhost:3000"
    $interval = 60
    $elasticServer = "server1:9200"

Download Powershell script (requires PS version 3+) from:

<https://github.com/trevorndodds/Powershell-grafana-scripts/blob/master/Grafana/grafana2elastic.ps1>

Run it as a windows service using nssm - <https://nssm.cc>


{
  "__inputs": [
    {
      "name": "DS_GRAFANA-METRICS",
      "label": "grafana-metrics",
      "description": "",
      "type": "datasource",
      "pluginId": "elasticsearch",
      "pluginName": "Elasticsearch"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "3.1.1"
    },
    {
      "type": "datasource",
      "id": "elasticsearch",
      "name": "Elasticsearch",
      "version": "3.0.0"
    }
  ],
  "id": null,
  "title": "Internal Grafana Stats (Elasticsearch)",
  "description": "Data Proxy request timings (percentiles), dashboard loads, logins etc, Elasticsearch version. ",
  "tags": [],
  "style": "dark",
  "timezone": "browser",
  "editable": true,
  "hideControls": true,
  "sharedCrosshair": false,
  "rows": [
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 3,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 7,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "{{field}}",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dataproxy_request_all.p25",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dataproxy_request_all.p75",
                  "id": "3",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dataproxy_request_all.p90",
                  "id": "4",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dataproxy_request_all.p99",
                  "id": "5",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode($prefix.$server.api.dataproxy.request.all.p*, 5)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Data Proxy Request Times (log base 10 scale)",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 2,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 10,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {
            "all": "#1F78C1",
            "request_all.count": "#6ED0E0"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 4,
          "interval": "60s",
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 5,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "request_all.count",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dataproxy_request_all.count",
                  "hide": true,
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode(scaleToSeconds($prefix.$server.api.dataproxy.request.all.count, 1), 4)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Data Proxy Requests / s",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    },
    {
      "collapse": false,
      "editable": true,
      "height": "200px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 1,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 7,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "{{field}}",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dashboard_search.p25",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dashboard_search.p75",
                  "id": "3",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dashboard_search.p90",
                  "id": "4",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "api_dashboard_search.p99",
                  "id": "5",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode($prefix.$server.api.dashboard.search.p*, 4)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Dashboard Search Time",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {
            "api_dashboard_search.count": "#EAB839",
            "count": "#EAB839"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 2,
          "interval": "60s",
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 5,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "search.count",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dashboard_search.count",
                  "hide": true,
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode(scaleToSeconds($prefix.$server.api.dashboard.search.count, 1), 4)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Dashboard Search Req / s",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "title": "Row"
    },
    {
      "collapse": false,
      "editable": true,
      "height": "200px",
      "panels": [
        {
          "aliasColors": {
            "mean": "#6ED0E0"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 5,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "count",
              "yaxis": 1
            }
          ],
          "span": 3,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "{{field}}",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dashboard_save.mean",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode($prefix.$server.api.dashboard.save.mean, 4)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Dashboard Save Time",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {
            "mean": "#EAB839"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 6,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "count",
              "yaxis": 1
            }
          ],
          "span": 3,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "{{field}}",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dashboard_get.mean",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "aliasByNode($prefix.$server.api.dashboard.get.mean, 4)",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Dashboard Get Time",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {
            "summarize(sumSeries(internal.api.login.*.count), \"10min\", \"sum\")": "#508642",
            "summarize(sumSeries(internal.api.login.*.count), \"5min\", \"sum\")": "#1F78C1"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 7,
          "interval": "60s",
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "count",
              "yaxis": 1
            }
          ],
          "span": 3,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "logins",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_login_post.count",
                  "hide": true,
                  "id": "1",
                  "inlineScript": null,
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "alias(summarize(sumSeries($prefix.$server.api.login.*.count), '10min', 'sum', false), 'logins')",
              "textEditor": false,
              "timeField": "@timestamp"
            },
            {
              "alias": "oauth logins",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_login_oauth.count",
                  "hide": true,
                  "id": "1",
                  "inlineScript": null,
                  "meta": {},
                  "settings": {},
                  "type": "sum"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "server:$server",
              "refId": "B",
              "target": "alias(summarize(sumSeries($prefix.$server.api.login.*.count), '10min', 'sum', false), 'logins')",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Logins / 1 min",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {
            "summarize(sumSeries(internal.api.dashboard.get.count), \"10min\", \"sum\")": "#EF843C",
            "summarize(sumSeries(internal.api.login.*.count), \"5min\", \"sum\")": "#1F78C1"
          },
          "bars": false,
          "datasource": "${DS_GRAFANA-METRICS}",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 8,
          "interval": "60s",
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "count",
              "yaxis": 1
            }
          ],
          "span": 3,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "get.count",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "api_dashboard_get.count",
                  "hide": true,
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "server:$server",
              "refId": "A",
              "target": "alias(summarize(sumSeries($prefix.$server.api.dashboard.get.count), '10min', 'sum', false), 'dashboard loads')",
              "textEditor": false,
              "timeField": "@timestamp"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Dashboard Loads / 1 min",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    }
  ],
  "time": {
    "from": "2016-10-17T13:07:54.186Z",
    "to": "2016-10-17T15:07:54.186Z"
  },
  "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": [
      {
        "current": {},
        "datasource": "${DS_GRAFANA-METRICS}",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "server",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"server\"}",
        "refresh": 1,
        "regex": "",
        "type": "query"
      }
    ]
  },
  "annotations": {
    "list": []
  },
  "refresh": false,
  "schemaVersion": 12,
  "version": 4,
  "links": [],
  "gnetId": 665
}