Grafana dashboard: Vessel Tracking
Description: Vessel tracking from Postgresql GPS records

**Vessel tracking using GPS records in Postgresql table**

Also the average speed and milleage and Last location from the table

{
  "__inputs": [
    {
      "name": "DS_POSTGRESQL",
      "label": "PostgreSQL",
      "description": "",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.5.2"
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "pr0ps-trackmap-panel",
      "name": "TrackMap",
      "version": "2.0.4"
    },
    {
      "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": 11459,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1577006793587,
  "links": [
    {
      "asDropdown": true,
      "icon": "external link",
      "keepTime": true,
      "tags": [
        "Tol Laut"
      ],
      "title": "Dashboard",
      "type": "dashboards"
    }
  ],
  "panels": [
    {
      "autoZoom": true,
      "datasource": "${DS_POSTGRESQL}",
      "gridPos": {
        "h": 21,
        "w": 18,
        "x": 0,
        "y": 0
      },
      "id": 4,
      "lineColor": "red",
      "maxDataPoints": 5000,
      "options": {},
      "pointColor": "royalblue",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  lat AS \"latitude\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "lat"
                ],
                "type": "column"
              },
              {
                "params": [
                  "latitude"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [],
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  lon AS \"longitude\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "lon"
                ],
                "type": "column"
              },
              {
                "params": [
                  "longitude"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [],
          "hide": true,
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  speed AS \"speed\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "C",
          "select": [
            [
              {
                "params": [
                  "speed"
                ],
                "type": "column"
              },
              {
                "params": [
                  "speed"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Vessel Tracking",
      "transparent": true,
      "type": "pr0ps-trackmap-panel"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_POSTGRESQL}",
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 18,
        "y": 0
      },
      "id": 6,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "decimals": 2,
            "mappings": [
              {
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 20,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 8
              },
              {
                "color": "red",
                "value": 15
              }
            ],
            "unit": "velocityknot"
          },
          "override": {},
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": true,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.5.2",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  speed AS \"Speed\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "speed"
                ],
                "type": "column"
              },
              {
                "params": [
                  "Speed"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Average Speed",
      "transparent": true,
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_POSTGRESQL}",
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 18,
        "y": 7
      },
      "id": 7,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "sum"
          ],
          "defaults": {
            "decimals": 2,
            "mappings": [
              {
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 5000,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 2000
              },
              {
                "color": "red",
                "value": 4000
              }
            ],
            "unit": "lengthmi"
          },
          "override": {},
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": true,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.5.2",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  distance AS \"Distance\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "distance"
                ],
                "type": "column"
              },
              {
                "params": [
                  "Distance"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Mileage",
      "transparent": true,
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "columns": [],
      "datasource": "${DS_POSTGRESQL}",
      "fontSize": "100%",
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 18,
        "y": 14
      },
      "id": 8,
      "links": [],
      "options": {},
      "pageSize": null,
      "pluginVersion": "6.5.1",
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "time",
          "type": "date"
        },
        {
          "alias": "Long Lat",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "Metric",
          "preserveFormat": true,
          "sanitize": true,
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Latitude",
          "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": 5,
          "mappingType": 1,
          "pattern": "Latitude",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Longitude",
          "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": 4,
          "mappingType": 1,
          "pattern": "Longitude",
          "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,
          "mappingType": 1,
          "pattern": "Port",
          "thresholds": [],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "SEA",
              "value": ""
            }
          ]
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  \"createdAt\" AS \"time\",\n  lat AS \"Latitude\",\n  lon AS \"Longitude\",\n  port AS \"Port\"\nFROM vessel_tracking\nWHERE\n  $__timeFilter(\"createdAt\") AND\n  name = '$vessel'\nORDER BY 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "lat"
                ],
                "type": "column"
              },
              {
                "params": [
                  "Latitude"
                ],
                "type": "alias"
              }
            ],
            [
              {
                "params": [
                  "lon"
                ],
                "type": "column"
              },
              {
                "params": [
                  "Longitude"
                ],
                "type": "alias"
              }
            ],
            [
              {
                "params": [
                  "port"
                ],
                "type": "column"
              },
              {
                "params": [
                  "Port"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vessel_tracking",
          "timeColumn": "\"createdAt\"",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'$vessel'"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Current Position",
      "transform": "table",
      "transparent": true,
      "type": "table"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 21,
  "style": "dark",
  "tags": [
    "Tol Laut"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_POSTGRESQL}",
        "definition": "select name from vessel_tracking",
        "hide": 0,
        "includeAll": false,
        "label": "Vessel",
        "multi": false,
        "name": "vessel",
        "options": [],
        "query": "select name from vessel_tracking",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Vessel Tracking",
  "uid": "CXVdEy-Wz",
  "version": 10,
  "description": "Vessel tracking from Postgresql GPS records"
}