Grafana dashboard: App Metrics - OAuth2 Client Monitoring - Elasticsearch
Description: Dashboard to visualize metrics captured by App Metrics ASP.NET Core Middleware allow monitoring API usage by OAuth2 clients -https://github.com/alhardy/AppMetrics

This dashboard is to be used with App Metrics Elasticsearch reporting, App Metrics is an open-source and cross-platform .NET library used to record metrics within an application. More specifically it is for use with the default metrics captured by App Metric's ASP.NET Core Middleware. See the documentation for more details http://app-metrics.io/web-application-monitoring/middleware.html and the main github repo - https://github.com/alhardy/AppMetrics.

{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "4.2.0"
    },
    {
      "type": "panel",
      "id": "grafana-piechart-panel",
      "name": "Pie Chart",
      "version": "1.1.4"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    }
  ],
  "annotations": {
    "list": []
  },
  "editable": true,
  "gnetId": 2143,
  "graphTooltip": 1,
  "hideControls": false,
  "id": null,
  "links": [],
  "refresh": "5s",
  "rows": [
    {
      "collapse": false,
      "height": "350",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "$datasource",
          "decimals": 2,
          "editable": true,
          "error": false,
          "fill": 1,
          "id": 3,
          "interval": "$summarize",
          "legend": {
            "alignAsTable": true,
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "rightSide": true,
            "show": true,
            "sort": "current",
            "sortDesc": false,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 12,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "[{{tags.client_id}}] {{tags.route}}",
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "tags.client_id",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "tags.route",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "asc",
                    "orderBy": "_term",
                    "size": "10"
                  },
                  "type": "terms"
                },
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "client_id"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "route"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "application.oauth2__request_rate",
              "metrics": [
                {
                  "field": "fields.rate1m",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "policy": "default",
              "query": "name:application.oauth2__request_rate AND tags.env:$environment AND tags.app:$application AND tags.client_id:$client_id AND tags.route:$route",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "rate1m"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "last"
                  }
                ]
              ],
              "tags": [
                {
                  "key": "client_id",
                  "operator": "=~",
                  "value": "/^$client_id$/"
                },
                {
                  "condition": "AND",
                  "key": "route",
                  "operator": "=~",
                  "value": "/^$route$/"
                },
                {
                  "condition": "AND",
                  "key": "env",
                  "operator": "=~",
                  "value": "/^$environment$/"
                },
                {
                  "condition": "AND",
                  "key": "app",
                  "operator": "=~",
                  "value": "/^$application$/"
                }
              ],
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Throughput",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 2,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "rpm",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "rpm",
              "label": "",
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    },
    {
      "collapse": false,
      "height": "300px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "$datasource",
          "decimals": 2,
          "editable": true,
          "error": false,
          "fill": 1,
          "id": 4,
          "interval": "$summarize",
          "legend": {
            "alignAsTable": true,
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "rightSide": true,
            "show": true,
            "sort": "current",
            "sortDesc": false,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 8,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "{{tags.client_id}} {{tags.route}}",
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "tags.client_id",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "tags.route",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "client_id"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "route"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "application.oauth2__error_rate",
              "metrics": [
                {
                  "field": "fields.rate1m",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "policy": "default",
              "query": "name:application.oauth2__error_rate AND tags.client_id:$client_id AND tags.route:$route",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "rate1m"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "last"
                  }
                ]
              ],
              "tags": [
                {
                  "key": "client_id",
                  "operator": "=~",
                  "value": "/^$client_id$/"
                },
                {
                  "condition": "AND",
                  "key": "route",
                  "operator": "=~",
                  "value": "/^$route$/"
                },
                {
                  "condition": "AND",
                  "key": "app",
                  "operator": "=~",
                  "value": "/^$application$/"
                },
                {
                  "condition": "AND",
                  "key": "env",
                  "operator": "=~",
                  "value": "/^$environment$/"
                }
              ],
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Error Rate",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 2,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "rpm",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "rpm",
              "label": "",
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "cacheTimeout": null,
          "combine": {
            "label": "Others",
            "threshold": 0
          },
          "datasource": "$datasource",
          "editable": true,
          "error": false,
          "fontSize": "80%",
          "format": "rpm",
          "id": 5,
          "interval": null,
          "legend": {
            "percentage": true,
            "show": true,
            "sort": null,
            "sortDesc": null,
            "values": false
          },
          "legendType": "Right side",
          "links": [],
          "maxDataPoints": 3,
          "nullPointMode": "connected",
          "pieType": "pie",
          "span": 4,
          "strokeWidth": 1,
          "targets": [
            {
              "alias": "",
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "tags.client_id",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "asc",
                    "orderBy": "1",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "tags.http_status_code",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "http_status_code"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "client_id"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "application.oauth2__error_rate",
              "metrics": [
                {
                  "field": "fields.rate1m",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "policy": "default",
              "query": "name:application.oauth2__error_rate AND tags.env:$environment AND tags.app:$application AND tags.client_id:$client_id AND tags.route:$route",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "rate1m"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "last"
                  }
                ]
              ],
              "tags": [
                {
                  "key": "client_id",
                  "operator": "=~",
                  "value": "/^$client_id$/"
                },
                {
                  "condition": "AND",
                  "key": "route",
                  "operator": "=~",
                  "value": "/^$route$/"
                },
                {
                  "condition": "AND",
                  "key": "app",
                  "operator": "=~",
                  "value": "/^$application$/"
                },
                {
                  "condition": "AND",
                  "key": "env",
                  "operator": "=~",
                  "value": "/^$environment$/"
                }
              ],
              "timeField": "@timestamp"
            }
          ],
          "title": "Errors",
          "type": "grafana-piechart-panel",
          "valueName": "current"
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    },
    {
      "collapse": false,
      "height": "350",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "$datasource",
          "editable": true,
          "error": false,
          "fill": 1,
          "id": 1,
          "interval": "$summarize",
          "legend": {
            "alignAsTable": true,
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "rightSide": true,
            "show": true,
            "sort": "current",
            "sortDesc": true,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": true,
          "steppedLine": false,
          "targets": [
            {
              "alias": "",
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "tags.client_id",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "tags.route",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "client_id"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "route"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "application.oauth2__post_size",
              "metrics": [
                {
                  "field": "fields.last",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "policy": "default",
              "query": "name:application.oauth2__post_size AND tags.env:$environment AND tags.app:$application AND tags.client_id:$client_id AND tags.route:$route",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "last"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "last"
                  }
                ]
              ],
              "tags": [
                {
                  "key": "client_id",
                  "operator": "=~",
                  "value": "/^$client_id$/"
                },
                {
                  "condition": "AND",
                  "key": "route",
                  "operator": "=~",
                  "value": "/^$route$/"
                },
                {
                  "condition": "AND",
                  "key": "app",
                  "operator": "=~",
                  "value": "/^$application$/"
                },
                {
                  "condition": "AND",
                  "key": "env",
                  "operator": "=~",
                  "value": "/^$environment$/"
                }
              ],
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Post Request Size",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "decbytes",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "datasource": "$datasource",
          "decimals": 2,
          "editable": true,
          "error": false,
          "fill": 1,
          "id": 2,
          "interval": "$summarize",
          "legend": {
            "alignAsTable": true,
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "rightSide": true,
            "show": true,
            "sort": "current",
            "sortDesc": true,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 1,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": true,
          "steppedLine": false,
          "targets": [
            {
              "alias": "",
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "tags.client_id",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "tags.route",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 0,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "0"
                  },
                  "type": "terms"
                },
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "client_id"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "route"
                  ],
                  "type": "tag"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "application.oauth2__put_size",
              "metrics": [
                {
                  "field": "fields.last",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "policy": "default",
              "query": "name:application.oauth2__put_size AND tags.env:$environment AND tags.app:$application AND tags.client_id:$client_id AND tags.route:$route",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "p95"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "last"
                  }
                ]
              ],
              "tags": [
                {
                  "key": "client_id",
                  "operator": "=~",
                  "value": "/^$client_id$/"
                },
                {
                  "condition": "AND",
                  "key": "route",
                  "operator": "=~",
                  "value": "/^$route$/"
                },
                {
                  "condition": "AND",
                  "key": "app",
                  "operator": "=~",
                  "value": "/^$application$/"
                },
                {
                  "condition": "AND",
                  "key": "env",
                  "operator": "=~",
                  "value": "/^$environment$/"
                }
              ],
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Put Request Size",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "decbytes",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "decbytes",
              "label": "",
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    }
  ],
  "schemaVersion": 14,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "$datasource",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "client_id",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"tags.client_id\"}",
        "refresh": 1,
        "regex": "",
        "sort": 1,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$datasource",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "route",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"tags.route\"}",
        "refresh": 1,
        "regex": "",
        "sort": 1,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      },
      {
        "current": {
          "text": "AppMetricsSandboxES",
          "value": "AppMetricsSandboxES"
        },
        "hide": 0,
        "label": null,
        "name": "datasource",
        "options": [],
        "query": "elasticsearch",
        "refresh": 1,
        "regex": "",
        "type": "datasource"
      },
      {
        "auto": false,
        "auto_count": 30,
        "auto_min": "10s",
        "current": {
          "text": "5s",
          "value": "5s"
        },
        "hide": 0,
        "label": null,
        "name": "summarize",
        "options": [
          {
            "selected": true,
            "text": "5s",
            "value": "5s"
          },
          {
            "selected": false,
            "text": "10s",
            "value": "10s"
          },
          {
            "selected": false,
            "text": "30s",
            "value": "30s"
          },
          {
            "selected": false,
            "text": "1m",
            "value": "1m"
          },
          {
            "selected": false,
            "text": "10m",
            "value": "10m"
          },
          {
            "selected": false,
            "text": "30m",
            "value": "30m"
          },
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "6h",
            "value": "6h"
          },
          {
            "selected": false,
            "text": "12h",
            "value": "12h"
          },
          {
            "selected": false,
            "text": "1d",
            "value": "1d"
          },
          {
            "selected": false,
            "text": "7d",
            "value": "7d"
          },
          {
            "selected": false,
            "text": "14d",
            "value": "14d"
          },
          {
            "selected": false,
            "text": "30d",
            "value": "30d"
          }
        ],
        "query": "5s,10s,30s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
        "refresh": 2,
        "type": "interval"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$datasource",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "application",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"tags.app\"}",
        "refresh": 1,
        "regex": "",
        "sort": 1,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$datasource",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "environment",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"tags.env\"}",
        "refresh": 1,
        "regex": "",
        "sort": 1,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-5m",
    "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"
    ]
  },
  "timezone": "browser",
  "title": "App Metrics - OAuth2 Client Monitoring - Elasticsearch",
  "version": 8,
  "description": "Dashboard to visualize metrics captured by App Metrics ASP.NET Core Middleware allow monitoring API usage by OAuth2 clients -https://github.com/alhardy/AppMetrics"
}