Grafana dashboard: NGINX / API / Host / Endpoint
Description: Nginx,OpenResty HTTP API performance monitoring based on Prometheus LUA library

related dashboards
- https://grafana.com/dashboards/10442
- https://grafana.com/dashboards/10443
- https://grafana.com/dashboards/10444
- https://grafana.com/dashboards/10445

please see a complete demo: https://github.com/zrbcool/prometheus-lua-nginx
it can use following to ran a demo quickly
```shell
docker-compose up
```

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS-NGINX",
      "label": "Prometheus-Nginx",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.2.1"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "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"
      }
    ]
  },
  "editable": true,
  "gnetId": 10444,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1561475448010,
  "links": [
    {
      "asDropdown": true,
      "icon": "external link",
      "keepTime": true,
      "tags": [
        "dashboard"
      ],
      "targetBlank": true,
      "title": "# Dashboard",
      "type": "dashboards"
    },
    {
      "asDropdown": true,
      "icon": "dashboard",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "http"
      ],
      "targetBlank": true,
      "title": "# HTTP",
      "tooltip": "# Dashboard",
      "type": "dashboards",
      "url": "/d/yCm50nzZz/1-dashboard"
    },
    {
      "asDropdown": true,
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "motan"
      ],
      "targetBlank": true,
      "title": "# Motan",
      "type": "dashboards"
    },
    {
      "asDropdown": true,
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "internal"
      ],
      "targetBlank": true,
      "title": "# Internal",
      "type": "dashboards"
    }
  ],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 126,
      "panels": [],
      "title": "Overall",
      "type": "row"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS-NGINX}",
      "fill": 1,
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 0,
        "y": 1
      },
      "id": 128,
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": false,
        "hideEmpty": true,
        "hideZero": true,
        "max": true,
        "min": false,
        "rightSide": true,
        "show": false,
        "sideWidth": null,
        "sort": "max",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {},
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(nginx_http_request_duration_seconds_count{host=~\"$host\", endpoint=~\"[[endpoint]]\",status!~\"2..|403\"}[1m])) by(fullurl) \n/ \nsum(rate(nginx_http_request_duration_seconds_count{host=~\"$host\", endpoint=~\"[[endpoint]]\"}[1m])) by(fullurl) * 100",
          "format": "time_series",
          "hide": true,
          "instant": false,
          "intervalFactor": 2,
          "legendFormat": "{{fullurl}}",
          "refId": "A"
        },
        {
          "expr": "job:nginx_http_request_duration_seconds_sum:err_rate_by_host_endpoint_fullurl{host=~\"$host\", endpoint=~\"$endpoint\"}",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "intervalFactor": 2,
          "legendFormat": "{{fullurl}}",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "ERROR Rate",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 3,
          "format": "percent",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "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_PROMETHEUS-NGINX}",
      "fill": 1,
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 8,
        "y": 1
      },
      "id": 112,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {},
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Summary",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "job:nginx_http_request_duration_seconds:qps_by_instance_host_endpoint_2XX{host=~\"$host\", endpoint=~\"$endpoint\"}",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 1,
          "legendFormat": "{{instance}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "2XX QPS By Instance",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "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
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": 1
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS-NGINX}",
      "fill": 1,
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 16,
        "y": 1
      },
      "id": 129,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {},
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Summary",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(job:nginx_http_request_duration_seconds:qps_by_instance_host_endpoint_2XX{host=~\"$host\", endpoint=~\"$endpoint\"})",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 1,
          "legendFormat": "2XX",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "QPS",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "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
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": 1
      }
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "id": 122,
      "panels": [],
      "title": "URL",
      "type": "row"
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS-NGINX}",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 8,
        "x": 0,
        "y": 6
      },
      "id": 116,
      "links": [],
      "options": {},
      "pageSize": 10,
      "scroll": false,
      "showHeader": true,
      "sort": {
        "col": 2,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "mappingType": 1,
          "pattern": "__name__",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "QPS",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "fullurl",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "topk(10, sum by(fullurl) (job:nginx_http_request_duration_seconds:qps_by_instance_host_endpoint_fullurl_2XX{host=~\"$host\", endpoint=~\"$endpoint\"}))",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "title": "TOP 10 QPS",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS-NGINX}",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 8,
        "x": 8,
        "y": 6
      },
      "id": 123,
      "links": [],
      "options": {},
      "pageSize": 10,
      "scroll": false,
      "showHeader": true,
      "sort": {
        "col": 2,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "mappingType": 1,
          "pattern": "__name__",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "4XX",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "fullurl",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "topk(10, sum by (fullurl)(increase(nginx_http_request_duration_seconds_count{host=~\"$host\", status=~\"40[^3]{1}|4[^0]{1}.\", endpoint=~\"$endpoint\"}[10m]))>0)",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "title": "TOP 10 4XX over 10min",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS-NGINX}",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 8,
        "x": 16,
        "y": 6
      },
      "id": 124,
      "links": [],
      "options": {},
      "pageSize": 10,
      "scroll": false,
      "showHeader": true,
      "sort": {
        "col": 2,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "mappingType": 1,
          "pattern": "__name__",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "5XX",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTargetBlank": true,
          "linkTooltip": "点击查看详情",
          "linkUrl": "/d/P0TkH67Zk/api-endpoint-url?var-host=$host&&var-endpoint=${endpoint}&&var-fullurl=${__cell_1}",
          "mappingType": 1,
          "pattern": "fullurl",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "topk(10, sum by (fullurl)(increase(nginx_http_request_duration_seconds_count{host=~\"$host\", status=~\"5..\", endpoint=~\"$endpoint\"}[10m]))>0)",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "title": "TOP 10 5XX over 10min",
      "transform": "table",
      "type": "table"
    }
  ],
  "refresh": false,
  "schemaVersion": 18,
  "style": "dark",
  "tags": [
    "nginx"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS-NGINX}",
        "definition": "label_values(nginx_http_request_duration_seconds_count, host)",
        "hide": 0,
        "includeAll": false,
        "label": "host",
        "multi": false,
        "name": "host",
        "options": [],
        "query": "label_values(nginx_http_request_duration_seconds_count, host)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS-NGINX}",
        "definition": "label_values(nginx_http_request_duration_seconds_count{host=~\"$host\"}, endpoint)",
        "hide": 0,
        "includeAll": false,
        "label": "endpoint",
        "multi": false,
        "name": "endpoint",
        "options": [],
        "query": "label_values(nginx_http_request_duration_seconds_count{host=~\"$host\"}, endpoint)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "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": "",
  "title": "NGINX / API / Host / Endpoint",
  "uid": "d9NTw37Wk",
  "version": 24,
  "description": "Nginx,OpenResty HTTP API performance monitoring based on Prometheus LUA library"
}