Grafana dashboard: Wakatime
Description: j2gg0s's wakatime dashboard


{
  "__inputs": [
    {
      "name": "DS_POSTGRESQL",
      "label": "PostgreSQL",
      "description": "",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.3.7"
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "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": 13954,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1614149352507,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_POSTGRESQL}",
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "string"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 7,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "/.*/",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "7.3.7",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select to_json(\"created_at\" at time zone 'Asia/Shanghai')#>>'{}' AS \"updated_at\" from heartbeat order by \"created_at\" desc limit 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "metric",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Last Updated At",
      "transparent": true,
      "type": "stat"
    },
    {
      "datasource": "${DS_POSTGRESQL}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {},
          "displayName": "$__cell_0",
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 4
      },
      "id": 2,
      "options": {
        "displayMode": "gradient",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": true
        },
        "showUnfilled": false
      },
      "pluginVersion": "7.3.7",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  \"category\" || '@' || \"day\",\n  sum(value)\nFROM (\nSELECT\n  to_char(date_trunc('day', time + INTERVAL '8h'), 'MM-DD')  as \"day\",\n  labels->>'category' AS \"category\",\n  value\nFROM metric\nWHERE\n  $__timeFilter(\"time\")\n  AND labels->>'category' = 'browsing'\n) AS s\nGROUP BY \"day\", \"category\"\nORDER BY day",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "metric",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "@Browsing",
      "transparent": true,
      "type": "bargauge"
    },
    {
      "datasource": "${DS_POSTGRESQL}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {},
          "displayName": "$__cell_0",
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 4
      },
      "id": 4,
      "options": {
        "displayMode": "basic",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": true
        },
        "showUnfilled": false
      },
      "pluginVersion": "7.3.7",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  \"project\",\n  sum(value) AS \"duration\"\nFROM (\nSELECT\n  to_char(date_trunc('day', time + INTERVAL '8h'), 'MM-DD')  as \"day\",\n  labels->>'category' AS \"category\",\n  trim(leading 'https://' from trim(leading 'http://' from labels->>'project')) AS \"project\",\n  value\nFROM metric\nWHERE\n  $__timeFilter(\"time\")\n  AND labels->>'category' = 'browsing'\n) AS s\nGROUP BY \"project\"\nORDER BY \"duration\" DESC\nLIMIT ${TopN};\n",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "metric",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "TopN@Browsing",
      "transparent": true,
      "type": "bargauge"
    },
    {
      "datasource": "${DS_POSTGRESQL}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {},
          "displayName": "$__cell_0",
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 13
      },
      "id": 3,
      "options": {
        "displayMode": "gradient",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": true
        },
        "showUnfilled": false
      },
      "pluginVersion": "7.3.7",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  \"category\" || '@' || \"day\",\n  sum(value)\nFROM (\nSELECT\n  to_char(date_trunc('day', time + INTERVAL '8h'), 'MM-DD')  as \"day\",\n  labels->>'category' AS \"category\",\n  value\nFROM metric\nWHERE\n  $__timeFilter(\"time\")\n  AND labels->>'category' = 'coding'\n) AS s\nGROUP BY \"day\", \"category\"\nORDER BY day",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "metric",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "@Coding",
      "transparent": true,
      "type": "bargauge"
    },
    {
      "datasource": "${DS_POSTGRESQL}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {},
          "displayName": "$__cell_0",
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 13
      },
      "id": 5,
      "options": {
        "displayMode": "basic",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": true
        },
        "showUnfilled": false
      },
      "pluginVersion": "7.3.7",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  \"project\",\n  sum(value) AS \"duration\"\nFROM (\nSELECT\n  to_char(date_trunc('day', time + INTERVAL '8h'), 'MM-DD')  as \"day\",\n  labels->>'category' AS \"category\",\n  labels->>'project' AS \"project\",\n  value\nFROM metric\nWHERE\n  $__timeFilter(\"time\")\n  AND labels->>'category' = 'coding'\n) AS s\nGROUP BY \"project\"\nORDER BY \"duration\" DESC\nLIMIT ${TopN};\n",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "metric",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "TopN@Coding",
      "transparent": true,
      "type": "bargauge"
    }
  ],
  "refresh": "1m",
  "schemaVersion": 26,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "selected": true,
          "text": "5",
          "value": "5"
        },
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "TopN",
        "options": [
          {
            "selected": true,
            "text": "5",
            "value": "5"
          },
          {
            "selected": false,
            "text": "10",
            "value": "10"
          },
          {
            "selected": false,
            "text": "20",
            "value": "20"
          },
          {
            "selected": false,
            "text": "50",
            "value": "50"
          },
          {
            "selected": false,
            "text": "100",
            "value": "100"
          }
        ],
        "query": "5,10,20,50,100",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Wakatime",
  "uid": "nC3SeFyMk",
  "version": 22,
  "description": "j2gg0s's wakatime dashboard"
}