CodeQuality by Metrix++ 1:Codebase
Visualize code quality metrics LoC (Lines of Code), CC (Cyclomatic Complexity) and resulting CCD (Cyclomatic Complexity Density) collected for your codebase by Metrix++ in Prometheus
This dashboard allows you to visualize code quality metrics
1. LoC (Lines of Code)
1. CC (Cyclomatic Complexity)
1. and the resulting CCD (Cyclomatic Complexity Density), as division of CD by LoC

(all 3 horizontally in successive columns) collected for your **codebase** (C/C++, C# and Java) by [Metrix++](https://metrixplusplus.github.io/home.html) in Prometheus.
For each metric, 3 graphs are rendered vertically showing successively:
1. total absolute for the current selection (**codebase**)
1. distribution of the total 1. over the next level items (**folders**)
1. deviation over the time of the total 1. by next level items (**folders**)

It is part of a set of 3 dashboards, linked for the sake of drilldown analysis:
1. **_[CodeQuality by Metrix++ 1:Overall](https://grafana.com/grafana/dashboards/13754)_**
1. _[CodeQuality by Metrix++ 2:Folder](https://grafana.com/grafana/dashboards/13755)_
1. _[CodeQuality by Metrix++ 3:File](https://grafana.com/grafana/dashboards/13756)_

**_[CodeQuality by Metrix++ 1:Overall](https://grafana.com/grafana/dashboards/13754)_** is designed as **first** dashboard used during analysis, showing overall metrics at **codebase** level up to (scolling down to) the next level information about **folders**, with support for drilldown to the next linked _[CodeQuality by Metrix++ 2:Folder](https://grafana.com/grafana/dashboards/13755)_.

First it requires you to put [Metrix++](https://metrixplusplus.github.io/home.html) in place for your codebase (C/C++, C# and Java), (see also its [github repo](https://github.com/metrixplusplus/metrixplusplus)), and to setup a Prometheus instance scraping the output of the following commands:
- `python metrix++.py view --ll=ERROR --format=prometheus`
- `python metrix++.py view --ll=ERROR --format=prometheus -- /home/mycodebase`
- `python metrix++.py view --ll=ERROR --format=prometheus -- /home/mycodebase/src`
- `python metrix++.py view --ll=ERROR --format=prometheus -- /home/mycodebase/src/main`
- `python metrix++.py view --ll=ERROR --format=prometheus -- /home/mycodebase/src/main/java`
- `python metrix++.py view --ll=ERROR --format=prometheus -- /home/mycodebase/src/main/java/Foo.java`
{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS_(VLEI)",
      "label": "Prometheus",
      "description": "Prometheus instance responsible for scraping Metrix++ metrics for your codebase",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "DS_METAINFO",
      "label": "metainfo",
      "description": "JSON datasource for meta information and events to be rendered as annotations, like build events",
      "type": "datasource",
      "pluginId": "simpod-json-datasource",
      "pluginName": "JSON"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.4.3"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "5.0.0"
    },
    {
      "type": "datasource",
      "id": "simpod-json-datasource",
      "name": "JSON",
      "version": "0.1.4"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": false,
        "iconColor": "rgba(0, 211, 255, 1)",
        "limit": 100,
        "name": "Show user annotations",
        "showIn": 0,
        "type": "dashboard"
      },
      {
        "datasource": "${DS_METAINFO}",
        "enable": true,
        "hide": false,
        "iconColor": "rgba(255, 96, 96, 1)",
        "limit": 100,
        "name": "Show build annotations",
        "query": "builds",
        "showIn": 0,
        "tags": [],
        "type": "tags"
      }
    ]
  },
  "editable": true,
  "gnetId": 13754,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1611099607184,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS_(VLEI)}",
      "decimals": 0,
      "description": "Lines of Code",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 7,
        "x": 0,
        "y": 0
      },
      "id": 3,
      "legend": {
        "avg": false,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_lines_code_total{job=~`${codebase:regex}`,file=~`./`}",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "LoC $codebase overall",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "LoC overall (total)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "transparent": false,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 0,
      "description": "Cyclomatic Complexity",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 7,
        "x": 7,
        "y": 0
      },
      "id": 2,
      "legend": {
        "avg": false,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_complexity_cyclomatic_total{job=~`${codebase:regex}`,file=~`./`}",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "CC $codebase overall",
          "refId": "D"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CC overall (total)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "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_(VLEI)}",
      "decimals": null,
      "description": "Cyclomatic Complexity Density",
      "fill": 0,
      "gridPos": {
        "h": 9,
        "w": 10,
        "x": 14,
        "y": 0
      },
      "id": 11,
      "legend": {
        "avg": false,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_complexity_cyclomatic_total{job=~`${codebase:regex}`,file=~`./`} / std_code_lines_code_total{job=~`${codebase:regex}`,file=~`./`}",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "CCD $codebase overall",
          "refId": "D"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CCD overall (total)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "transparent": true,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 0,
      "description": "Lines of Code",
      "fill": 1,
      "gridPos": {
        "h": 11,
        "w": 7,
        "x": 0,
        "y": 9
      },
      "id": 10,
      "legend": {
        "avg": false,
        "current": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "minSpan": 3,
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeatDirection": "v",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_lines_code_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"}",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{file}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "LoC (folder distribution)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 0,
      "description": "Cyclomatic Complexity",
      "fill": 1,
      "gridPos": {
        "h": 11,
        "w": 7,
        "x": 7,
        "y": 9
      },
      "id": 9,
      "legend": {
        "avg": false,
        "current": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeatDirection": null,
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_complexity_cyclomatic_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"}",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 1,
          "legendFormat": "{{file}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CC (folder distribution)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 9,
      "description": "Cyclomatic Complexity Density",
      "fill": 0,
      "gridPos": {
        "h": 11,
        "w": 10,
        "x": 14,
        "y": 9
      },
      "id": 12,
      "legend": {
        "avg": false,
        "current": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeatDirection": null,
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "std_code_complexity_cyclomatic_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"} / std_code_lines_code_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"}",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 1,
          "legendFormat": "{{file}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CCD (folder distribution)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "transparent": true,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 0,
      "description": "Lines of Code",
      "fill": 1,
      "gridPos": {
        "h": 11,
        "w": 7,
        "x": 0,
        "y": 20
      },
      "id": 7,
      "legend": {
        "avg": false,
        "current": false,
        "hideZero": true,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [
        {
          "dashboard": "CodeQuality by Metrix++ 2:Folder",
          "includeVars": true,
          "keepTime": true,
          "targetBlank": true,
          "title": "CodeQuality by Metrix++ 2:Folder",
          "type": "dashboard",
          "url": "/grafana/d/2KZTZB1Mk/codequality-by-metrixpp-2-folder"
        }
      ],
      "minSpan": 3,
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeatDirection": "v",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "delta(std_code_lines_code_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"}[$deltaTimeRange])",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{file}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "LoC by folder (deviation)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "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_(VLEI)}",
      "decimals": 0,
      "description": "Cyclomatic Complexity",
      "fill": 1,
      "gridPos": {
        "h": 11,
        "w": 7,
        "x": 7,
        "y": 20
      },
      "id": 8,
      "legend": {
        "avg": false,
        "current": false,
        "hideZero": true,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [
        {
          "dashboard": "CodeQuality by Metrix++ 2:Folder",
          "includeVars": true,
          "keepTime": true,
          "targetBlank": true,
          "title": "CodeQuality by Metrix++ 2:Folder",
          "type": "dashboard",
          "url": "/grafana/d/2KZTZB1Mk/codequality-by-metrixpp-2-folder"
        }
      ],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeatDirection": null,
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "delta(std_code_complexity_cyclomatic_total{job=~`${codebase:regex}`,file!~\".*(cpp|h|java)\"}[$deltaTimeRange])",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 1,
          "legendFormat": "{{file}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CC by folder (deviation)",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 0,
          "format": "none",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": false,
  "schemaVersion": 16,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": ".*",
        "current": {},
        "datasource": "${DS_PROMETHEUS_(VLEI)}",
        "definition": "label_values(std_code_lines_code_total{},job)",
        "hide": 0,
        "includeAll": false,
        "label": "Codebase",
        "multi": false,
        "name": "codebase",
        "options": [],
        "query": "label_values(std_code_lines_code_total{},job)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {
          "tags": [],
          "text": "1h",
          "value": "1h"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Delta time range",
        "multi": false,
        "name": "deltaTimeRange",
        "options": [
          {
            "selected": false,
            "text": "1m",
            "value": "1m"
          },
          {
            "selected": true,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "1d",
            "value": "1d"
          },
          {
            "selected": false,
            "text": "1w",
            "value": "1w"
          }
        ],
        "query": "1m, 1h, 1d, 1w",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-7d",
    "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": "CodeQuality by Metrix++ 1:Codebase",
  "uid": "x9C1mYJMk",
  "version": 26,
  "description": "Visualize code quality metrics LoC (Lines of Code), CC (Cyclomatic Complexity) and resulting CCD (Cyclomatic Complexity Density) collected for your codebase by Metrix++ in Prometheus"
}