{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 2,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 4,
      "panels": [],
      "title": "Key Performance Indicators",
      "type": "row"
    },
    {
      "datasource": {
        "uid": "Redshift Streaming"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "green",
            "mode": "fixed"
          },
          "decimals": 2,
          "mappings": [],
          "max": -1,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Cost  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "continuous-BlYlRd"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Profit  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "purple",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Average Delivery Days  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "orange",
                  "mode": "fixed"
                }
              },
              {
                "id": "decimals"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Number of Consignments  "
            },
            "properties": [
              {
                "id": "unit"
              },
              {
                "id": "decimals"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "yellow",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 17,
        "x": 3,
        "y": 1
      },
      "id": 2,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.4.7",
      "targets": [
        {
          "rawSQL": "select \nsum(revenue) as \" \" from consignment_predictions\nwhere $__timeFilter(consignment_date)",
          "refId": "Revenue"
        },
        {
          "hide": false,
          "rawSQL": "select sum(cost) as \" \" from consignment_predictions\nwhere $__timeFilter(consignment_date)",
          "refId": "Cost"
        },
        {
          "hide": false,
          "rawSQL": "select sum(revenue - cost) as \" \" from consignment_predictions\nwhere $__timeFilter(consignment_date)",
          "refId": "Profit"
        },
        {
          "hide": false,
          "rawSQL": "select avg(days_to_deliver) as \" \" from consignment_predictions\nwhere $__timeFilter(consignment_date)",
          "refId": "Average Delivery Days"
        },
        {
          "hide": false,
          "rawSQL": "select count(1) as \" \" from consignment_predictions\nwhere $__timeFilter(consignment_date)",
          "refId": "Number of Consignments"
        }
      ],
      "transparent": true,
      "type": "stat"
    },
    {
      "datasource": {
        "uid": "Redshift Streaming"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 22,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "line"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 40
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "High Probability  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Medium Probability  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "yellow",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Low Probability  "
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "green",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 9,
        "w": 13,
        "x": 0,
        "y": 4
      },
      "id": 6,
      "interval": "1m",
      "maxDataPoints": 100,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "8.2.5",
      "targets": [
        {
          "hide": false,
          "rawSQL": "select $__timeGroup(consignment_date, $__interval),\ncount(case when delay_probability = 'HIGH' THEN 1 END) as \" \"\nfrom consignment_predictions\ngroup by 1\norder by 1",
          "refId": "High Probability"
        },
        {
          "hide": false,
          "rawSQL": "select $__timeGroup(consignment_date, $__interval),\ncount(case when delay_probability = 'MEDIUM' THEN 1 END) as \" \"\nfrom consignment_predictions\ngroup by 1\norder by 1",
          "refId": "Medium Probability"
        },
        {
          "rawSQL": "select $__timeGroup(consignment_date, $__interval),\ncount(case when delay_probability = 'LOW' THEN 1 END) as \" \"\nfrom consignment_predictions\ngroup by 1\norder by 1",
          "refId": "Low Probability"
        }
      ],
      "title": "Delay Probability",
      "transparent": true,
      "type": "timeseries"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "continuous-RdYlGr"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "fillOpacity": 44,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 1,
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 11,
        "x": 13,
        "y": 4
      },
      "id": 10,
      "options": {
        "barRadius": 0,
        "barWidth": 0.6,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom"
        },
        "orientation": "horizontal",
        "showValue": "auto",
        "stacking": "normal",
        "text": {},
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "xTickLabelRotation": 0,
        "xTickLabelSpacing": 0
      },
      "pluginVersion": "8.2.5",
      "targets": [
        {
          "datasource": {
            "type": "grafana-redshift-datasource",
            "uid": "4ARHM404k"
          },
          "rawSQL": "select destination_state as \"Destination\",  \ncount (case when delay_probability = 'HIGH' then 1 end) as \"high delay\",\ncount(1) as \"Total consignment count\"\nfrom consignment_predictions\nwhere $__timeFilter(consignment_date)\ngroup by destination_state \norder by destination_state",
          "refId": "A"
        }
      ],
      "title": "Consignment by State",
      "transparent": true,
      "type": "barchart"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "filterable": true
          },
          "mappings": [
            {
              "options": {
                "HIGH": {
                  "color": "red",
                  "index": 2
                },
                "LOW": {
                  "color": "green",
                  "index": 0
                },
                "MEDIUM": {
                  "color": "orange",
                  "index": 1
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "origin"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Origin"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "destination"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Destination"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "consignmentid"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "ID"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "delay_probability"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Delay Probability"
              },
              {
                "id": "custom.displayMode",
                "value": "color-text"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "delivery_distance"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Distance"
              },
              {
                "id": "custom.displayMode",
                "value": "basic"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-GrYlRd"
                }
              },
              {
                "id": "custom.filterable"
              },
              {
                "id": "min",
                "value": 0
              },
              {
                "id": "max",
                "value": 1200
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "revenue"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Revenue"
              },
              {
                "id": "custom.filterable"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "cost"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Cost"
              },
              {
                "id": "custom.filterable"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Origin"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 104
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Destination"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 117
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Cost"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 0
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 11,
        "w": 13,
        "x": 0,
        "y": 13
      },
      "id": 8,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "8.4.7",
      "targets": [
        {
          "datasource": {
            "type": "grafana-redshift-datasource",
            "uid": "4ARHM404k"
          },
          "rawSQL": "select top 100 consignment_id, origin_state as \"Origin\", destination_state as \"Destination\", delay_probability, delivery_distance, revenue, cost from consignment_predictions\nwhere $__timeFilter(consignment_date)\norder by consignment_date desc",
          "refId": "A"
        }
      ],
      "title": "Recent Transactions",
      "type": "table"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "vehicle_location"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Vehicle Location"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "on_the_move"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "On the Move"
              },
              {
                "id": "custom.displayMode",
                "value": "gradient-gauge"
              },
              {
                "id": "color"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "percentage",
                  "steps": [
                    {
                      "color": "orange",
                      "value": null
                    },
                    {
                      "color": "green",
                      "value": 80
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "scheduled_maintenance"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Scheduled Maintenance"
              },
              {
                "id": "custom.displayMode",
                "value": "gradient-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "thresholds"
                }
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "percentage",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    },
                    {
                      "color": "red",
                      "value": 10
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "unscheduled_maintenance"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Unscheduled Maintenance"
              },
              {
                "id": "custom.displayMode",
                "value": "gradient-gauge"
              },
              {
                "id": "color"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "percentage",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    },
                    {
                      "color": "red",
                      "value": 5
                    }
                  ]
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 11,
        "w": 11,
        "x": 13,
        "y": 13
      },
      "id": 12,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "8.4.7",
      "targets": [
        {
          "datasource": {
            "type": "grafana-redshift-datasource",
            "uid": "4ARHM404k"
          },
          "rawSQL": "select * from fleet_summary ",
          "refId": "A"
        }
      ],
      "title": "Panel Title",
      "type": "table"
    }
  ],
  "refresh": "5s",
  "schemaVersion": 35,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-3h",
    "to": "now-1m"
  },
  "timepicker": {
    "nowDelay": "1m"
  },
  "timezone": "",
  "title": "Logistics Dashboard",
  "uid": "oE82Z2Bnk",
  "version": 2,
  "weekStart": ""
}