GraphQL example
Sample dashboard demonstrating the GraphQL datasource plugin
This is a sample dashboard demonstrating the features of the [GraphQL datasource
plugin](https://grafana.com/grafana/plugins/fifemon-graphql-datasource/). It uses the [FIFEmon GraphQL test source server](https://github.com/retzkek/graphql-test-source/)

## Usage

1. Run the server with [leiningen](https://github.com/technomancy/leiningen):

    `lein run`
    
    or with Docker:
    
    `docker run -it --rm -p 8888:8888 retzkek/graphql-test-source`
    
2. [Install
   Grafana](https://grafana.com/docs/grafana/latest/installation/?pg=docs) and
   the [GraphQL Datasource
   Plugin](https://grafana.com/grafana/plugins/fifemon-graphql-datasource/?tab=installation).

3. Add a GraphQL Datasource to Grafana pointing at the server (`http://localhost:8888/api`)

5. Import the [sample dashboard](https://grafana.com/grafana/dashboards/14079) into Grafana.

{
  "__inputs": [
    {
      "name": "DS_TEST",
      "label": "test",
      "description": "graphql-test-source server",
      "type": "datasource",
      "pluginId": "fifemon-graphql-datasource",
      "pluginName": "GraphQL Data Source"
    }
  ],
  "__requires": [
    {
      "type": "datasource",
      "id": "fifemon-graphql-datasource",
      "name": "GraphQL Data Source",
      "version": "1.2.0"
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.4.2"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      },
      {
        "aliasBy": "",
        "annotationTags": "$field_tags.0",
        "annotationText": "$field_description",
        "annotationTitle": "$field_name",
        "constant": 6.5,
        "dataPath": "events",
        "datasource": "${DS_TEST}",
        "enable": true,
        "endTimePath": "endTime",
        "groupBy": "",
        "hide": false,
        "iconColor": "rgba(255, 96, 96, 1)",
        "name": "event",
        "queryText": "query {\n  events(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",format:\"MM.dd.uuuu HHmmss\") {\n    timestamp\n    name\n    description\n    tags\n  }\n}",
        "showIn": 0,
        "timeFormat": "MM.DD.YYYY HHmmss",
        "timePath": "timestamp"
      },
      {
        "aliasBy": "",
        "annotationTags": "$field_tags.0",
        "annotationText": "$field_description",
        "annotationTitle": "$field_name",
        "constant": 6.5,
        "dataPath": "events",
        "datasource": "${DS_TEST}",
        "enable": true,
        "endTimePath": "end_timestamp",
        "groupBy": "",
        "hide": false,
        "iconColor": "#FADE2A",
        "name": "span",
        "queryText": "query {\n  events(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",end:true) {\n    timestamp\n    end_timestamp\n    name\n    description\n    tags\n  }\n}",
        "showIn": 0,
        "timeFormat": "",
        "timePath": "timestamp"
      }
    ]
  },
  "editable": true,
  "gnetId": 14079,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1615910833605,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 2,
      "interval": null,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.4.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "aliasBy": "",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "simple_series",
          "groupBy": "",
          "queryText": "query {\n  simple_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms) {\n    timestamp value\n  }\n}\n",
          "refId": "A",
          "timeFormat": null,
          "timePath": "timestamp"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "simple_series",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:297",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:298",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 3,
      "interval": null,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.4.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "aliasBy": "",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "complex_series",
          "groupBy": "",
          "queryText": "query {\n  complex_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms) {\n    time {timestamp}\n    value\n  }\n}\n",
          "refId": "A",
          "timeFormat": null,
          "timePath": "time.timestamp"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "complex series with time path",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:297",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:298",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 5,
      "interval": null,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.4.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "aliasBy": "",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "simple_series",
          "groupBy": "",
          "queryText": "query {\n  simple_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms,format:\"MM.dd.uuuu HHmmss\") {\n    timestamp value\n  }\n}\n",
          "refId": "A",
          "timeFormat": "MM.DD.YYYY HHmmss",
          "timePath": "timestamp"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "time format",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:297",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:298",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 4,
      "interval": null,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.4.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "aliasBy": "$field_group.name",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "complex_series",
          "groupBy": "group.id",
          "queryText": "query {\n  complex_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms) {\n    time {timestamp}\n    value\n    group {id name}\n  }\n}\n",
          "refId": "A",
          "timeFormat": null,
          "timePath": "time.timestamp"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "group and alias",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:297",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:298",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 18
      },
      "hiddenSeries": false,
      "id": 7,
      "interval": null,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.4.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "aliasBy": "$field_group.name",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "complex_series",
          "endTimePath": "endTime",
          "groupBy": "group.id",
          "queryText": "query {\n  complex_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms,group_id:\"$group_kv\") {\n    time {timestamp}\n    value\n    group {id name}\n  }\n}\n",
          "refId": "A",
          "timeFormat": null,
          "timePath": "time.timestamp"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "group variable",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:297",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:298",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "datasource": "${DS_TEST}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": null,
            "filterable": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": []
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 18
      },
      "id": 6,
      "interval": null,
      "options": {
        "showHeader": true
      },
      "pluginVersion": "7.4.2",
      "targets": [
        {
          "aliasBy": "",
          "annotationTags": "",
          "annotationText": "",
          "annotationTitle": "",
          "constant": 6.5,
          "dataPath": "complex_series",
          "groupBy": "",
          "queryText": "query {\n  complex_series(from:\"${__from:date:iso}\",to:\"${__to:date:iso}\",interval_ms:$__interval_ms) {\n    time {timestamp}\n    value\n    group {id name}\n  }\n}\n",
          "refId": "A",
          "timeFormat": null,
          "timePath": "time.timestamp"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "transform",
      "transformations": [
        {
          "id": "groupBy",
          "options": {
            "fields": {
              "group.name": {
                "aggregations": [],
                "operation": "groupby"
              },
              "value": {
                "aggregations": [
                  "min",
                  "max",
                  "mean"
                ],
                "operation": "aggregate"
              }
            }
          }
        }
      ],
      "type": "table"
    }
  ],
  "refresh": false,
  "schemaVersion": 27,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_TEST}",
        "definition": "query {\n  groups{ __value:id __text:name }\n} (groups)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "group_kv",
        "options": [],
        "query": {
          "dataPath": "groups",
          "queryText": "query {\n  groups{ __value:id __text:name }\n}"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_TEST}",
        "definition": "query {\n  groups{ id name }\n} (groups)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "group_id_name",
        "options": [],
        "query": {
          "dataPath": "groups",
          "queryText": "query {\n  groups{ id name }\n}"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "GraphQL example",
  "uid": "YIhuYE8Gk",
  "version": 10,
  "description": "Sample dashboard demonstrating the GraphQL datasource plugin"
}