Grafana dashboard: heaven_es采集成功率统计
Description: es采集日志条数前后对比


{
  "__inputs": [
    {
      "name": "elasticsearch DB Source",
      "label": "Select DB Source",
      "description": "请选择数据源",
      "type": "datasource",
      "pluginId": "elasticsearch",
      "pluginName": "elasticsearch"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.2.2"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "6.2.2"
    },
    {
      "type": "datasource",
      "id": "elasticsearch",
      "name": "elasticsearch",
      "version": "6.8.1"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 12549,
  "graphTooltip": 0,
  "id": 35,
  "iteration": 1593485696791,
  "links": [],
  "panels": [
    {
      "columns": [],
      "datasource": "es_drate",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 6,
      "interval": "$interval",
      "links": [],
      "options": {},
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 3,
        "desc": true
      },
      "styles": [
        {
          "alias": "业务系统",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "appsystem.keyword",
          "type": "string"
        },
        {
          "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": 0,
          "mappingType": 1,
          "pattern": "Sum topic_doc_count",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "入库es数量",
          "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": 0,
          "mappingType": 1,
          "pattern": "Sum es_doc_count",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "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": 0,
          "mappingType": 1,
          "pattern": "Sum diff",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "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": 6,
          "mappingType": 1,
          "pattern": "Average",
          "thresholds": [],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "bucketAggs": [
            {
              "fake": true,
              "field": "appsystem.keyword",
              "id": "7",
              "settings": {
                "min_doc_count": 1,
                "order": "desc",
                "orderBy": "5",
                "size": "100"
              },
              "type": "terms"
            }
          ],
          "metrics": [
            {
              "field": "topic_doc_count",
              "id": "1",
              "meta": {},
              "settings": {},
              "type": "sum"
            },
            {
              "field": "es_doc_count",
              "id": "4",
              "meta": {},
              "settings": {},
              "type": "sum"
            },
            {
              "field": "diff",
              "id": "5",
              "meta": {},
              "settings": {},
              "type": "sum"
            },
            {
              "field": "success_rate",
              "id": "6",
              "meta": {},
              "settings": {},
              "type": "avg"
            }
          ],
          "query": "NOT success_rate:0 AND appsystem:$appsystem",
          "refId": "A",
          "timeField": "collecTime"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "成功率报表汇总展示",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "index_name",
          "value": "index_name"
        },
        {
          "text": "appsystem",
          "value": "appsystem"
        },
        {
          "text": "topic_doc_count",
          "value": "topic_doc_count"
        },
        {
          "text": "es_doc_count",
          "value": "es_doc_count"
        },
        {
          "text": "diff",
          "value": "diff"
        },
        {
          "text": "collecTime",
          "value": "collecTime"
        },
        {
          "text": "success_rate",
          "value": "success_rate"
        }
      ],
      "datasource": "es_drate",
      "fontSize": "100%",
      "gridPos": {
        "h": 14,
        "w": 24,
        "x": 0,
        "y": 10
      },
      "id": 4,
      "interval": "$interval",
      "links": [],
      "options": {},
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 6,
        "desc": true
      },
      "styles": [
        {
          "alias": "ES索引",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "index_name",
          "type": "string"
        },
        {
          "alias": "源日志数量",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": null,
          "pattern": "topic_doc_count",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "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": null,
          "mappingType": 1,
          "pattern": "es_doc_count",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "采集成功率",
          "colorMode": "cell",
          "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": 3,
          "mappingType": 1,
          "pattern": "success_rate",
          "thresholds": [
            "99",
            "99.9"
          ],
          "type": "number",
          "unit": "percent"
        },
        {
          "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": 0,
          "mappingType": 1,
          "pattern": "diff",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "appsystem",
          "thresholds": [],
          "type": "string",
          "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,
          "mappingType": 1,
          "pattern": "collecTime",
          "thresholds": [],
          "type": "date",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "bucketAggs": [],
          "metrics": [
            {
              "field": "success_rate",
              "id": "1",
              "meta": {},
              "settings": {
                "size": 2000
              },
              "type": "raw_document"
            }
          ],
          "query": "NOT success_rate:0  AND appsystem:$appsystem",
          "refId": "A",
          "timeField": "collecTime"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "每小时采集成功率",
      "transform": "json",
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "es_drate",
      "fill": 1,
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 24
      },
      "id": 2,
      "interval": "$interval",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "hideEmpty": true,
        "hideZero": true,
        "max": true,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {},
      "percentage": false,
      "pointradius": 2,
      "points": true,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "bucketAggs": [
            {
              "fake": true,
              "field": "appsystem.keyword",
              "id": "3",
              "settings": {
                "min_doc_count": 1,
                "order": "desc",
                "orderBy": "1",
                "size": "5"
              },
              "type": "terms"
            },
            {
              "field": "collecTime",
              "id": "2",
              "settings": {
                "interval": "auto",
                "min_doc_count": 0,
                "trimEdges": 0
              },
              "type": "date_histogram"
            }
          ],
          "metrics": [
            {
              "field": "success_rate",
              "id": "1",
              "meta": {},
              "settings": {},
              "type": "avg"
            }
          ],
          "query": "NOT success_rate:0  AND appsystem:$appsystem",
          "refId": "A",
          "timeField": "collecTime"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "采集成功率趋势图",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "percent",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": "80",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": false,
  "schemaVersion": 18,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": "*",
        "current": {
          "text": "All",
          "value": [
            "$__all"
          ]
        },
        "datasource": "es_drate",
        "definition": "{\"find\" : \"terms\" , \"field\" : \"appsystem.keyword\"}",
        "hide": 0,
        "includeAll": true,
        "label": "业务系统",
        "multi": true,
        "name": "appsystem",
        "options": [],
        "query": "{\"find\" : \"terms\" , \"field\" : \"appsystem.keyword\"}",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "auto": false,
        "auto_count": 30,
        "auto_min": "10s",
        "current": {
          "text": "1h",
          "value": "1h"
        },
        "hide": 0,
        "label": "计算频率",
        "name": "interval",
        "options": [
          {
            "selected": true,
            "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": "1h,6h,12h,1d,7d,14d,30d",
        "refresh": 2,
        "skipUrlSync": false,
        "type": "interval"
      }
    ]
  },
  "time": {
    "from": "now-1d/d",
    "to": "now-1d/d"
  },
  "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": "heaven_es采集成功率统计",
  "uid": "h3V5E8gGz",
  "version": 50,
  "description": "es采集日志条数前后对比"
}