Skip to content

Instantly share code, notes, and snippets.

@sanfx
Last active April 25, 2020 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanfx/42b0519ba4d6e07f4790cbb2eb20e3df to your computer and use it in GitHub Desktop.
Save sanfx/42b0519ba4d6e07f4790cbb2eb20e3df to your computer and use it in GitHub Desktop.
Panel in grafana I made that reads data from mysql server and computes dew point and heat index using sql query using in grafana.
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "MySQL-1",
"decimals": 2,
"fill": 7,
"fillGradient": 0,
"gridPos": {
"h": 5,
"w": 12,
"x": 0,
"y": 0
},
"hiddenSeries": false,
"hideTimeOverride": true,
"id": 11,
"interval": "1h",
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"hideEmpty": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 0.5,
"points": true,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "cost_per_gbp",
"lines": true
},
{
"alias": "cost_per_gbp",
"legend": true,
"zindex": 2
},
{
"alias": "cost_per_gbp",
"stack": "A",
"yaxis": 2
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n cost_per_gbp\nFROM inr_gbp_tbl\nORDER BY datetime_added",
"refId": "A",
"select": [
[
{
"params": [
"cost_per_gbp"
],
"type": "column"
}
]
],
"table": "inr_gbp_tbl",
"timeColumn": "cost_per_gbp",
"timeColumnType": "float",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": "10h",
"title": "GBP currency in INR",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": "199",
"min": "80",
"show": false
},
{
"format": "short",
"label": "INR",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorPrefix": false,
"colorValue": false,
"colors": [
"rgb(114, 26, 148)",
"#8AB8FF",
"#F2495C"
],
"datasource": "MySQL-1",
"decimals": 2,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 2,
"w": 5,
"x": 12,
"y": 0
},
"id": 14,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": " INR",
"postfixFontSize": "50%",
"prefix": "1 USD =",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false,
"ymax": null,
"ymin": null
},
"tableColumn": "",
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n rate_per_usd\nFROM inr_usd_tbl\nORDER BY id DESC\nLIMIt 1",
"refId": "A",
"select": [
[
{
"params": [
"rate_per_usd"
],
"type": "column"
}
]
],
"table": "inr_usd_tbl",
"timeColumn": "datetime_added",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": "",
"timeFrom": null,
"timeShift": null,
"title": "Last Registered Currency Exchange Rate",
"type": "singlestat",
"valueFontSize": "50%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorPrefix": false,
"colorValue": false,
"colors": [
"#299c46",
"#FFB357",
"#F2495C"
],
"datasource": "MySQL-1",
"decimals": 2,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 1,
"w": 5,
"x": 12,
"y": 2
},
"id": 15,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": " GBP",
"postfixFontSize": "50%",
"prefix": "1 USD =",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": true,
"lineColor": "#F2495C",
"show": false,
"ymax": null,
"ymin": null
},
"tableColumn": "",
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n rate_per_usd\nFROM gbp_usd_tbl\nORDER BY id DESC\nLIMIt 1",
"refId": "A",
"select": [
[
{
"params": [
"rate_per_usd"
],
"type": "column"
}
]
],
"table": "gbp_usd_tbl",
"timeColumn": "datetime_added",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": "",
"timeFrom": null,
"timeShift": null,
"title": "",
"type": "singlestat",
"valueFontSize": "50%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorPrefix": false,
"colorValue": false,
"colors": [
"#1F60C4",
"#8AB8FF",
"#299c46"
],
"datasource": "MySQL-1",
"decimals": 2,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 1,
"w": 5,
"x": 12,
"y": 3
},
"id": 13,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": " INR",
"postfixFontSize": "50%",
"prefix": "1 GBP =",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false,
"ymax": null,
"ymin": null
},
"tableColumn": "",
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n cost_per_gbp\nFROM inr_gbp_tbl\nORDER BY id DESC\nLIMIt 1",
"refId": "A",
"select": [
[
{
"params": [
"cost_per_gbp"
],
"type": "column"
}
]
],
"table": "inr_gbp_tbl",
"timeColumn": "datetime_added",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": "",
"timeFrom": null,
"timeShift": null,
"title": "",
"type": "singlestat",
"valueFontSize": "50%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"aliasColors": {
"download_speed": "dark-purple",
"downoad_speed": "super-light-blue",
"upload_speed": "dark-yellow"
},
"bars": true,
"dashLength": 10,
"dashes": false,
"datasource": "MySQL-1",
"description": "",
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 5
},
"hiddenSeries": false,
"id": 17,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 1,
"nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 1,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "download_speed",
"yaxis": 2
},
{
"alias": "upload_speed",
"yaxis": 2
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n (download * 8) AS \"download_speed\"\nFROM speed_test_table\nWHERE\n $__timeFilter(datetime_added)\nORDER BY datetime_added",
"refId": "A",
"select": [
[
{
"params": [
"download"
],
"type": "column"
}
],
[
{
"params": [
"upload"
],
"type": "column"
}
]
],
"table": "speed_test_table",
"timeColumn": "datetime_added",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
},
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n datetime_added AS \"time\",\n (upload * 8) AS \"upload_speed\"\nFROM speed_test_table\nWHERE\n $__timeFilter(datetime_added)\nORDER BY datetime_added",
"refId": "B",
"select": [
[
{
"params": [
"download"
],
"type": "column"
}
],
[
{
"params": [
"upload"
],
"type": "column"
}
]
],
"table": "speed_test_table",
"timeColumn": "datetime_added",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Internet Speed",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
},
{
"decimals": 2,
"format": "Mbits",
"label": "Speed",
"logBase": 1,
"max": null,
"min": "0",
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {
"Feels Like": "rgb(255, 0, 230)",
"Temperature": "light-blue",
"dewpoint": "rgba(240, 40, 40, 0.79)",
"humidity": "rgb(0, 143, 23)",
"temp": "rgba(7, 228, 242, 0.78)"
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "MySQLRockPro",
"decimals": 2,
"description": "Bedroom temperature, humidity , dewpoint",
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 14
},
"hiddenSeries": false,
"id": 4,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"hideEmpty": false,
"hideZero": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "Dew Point",
"yaxis": 2
},
{
"alias": "Temperature",
"lines": true,
"yaxis": 2
},
{
"alias": "temp_f",
"fill": 0,
"hideTooltip": true,
"lines": false,
"yaxis": 1
},
{
"alias": "Feels Like",
"lines": true,
"yaxis": 2
},
{
"alias": "Humidity",
"legend": false,
"lines": false,
"yaxis": 1
},
{
"alias": "temp_f",
"legend": false
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n dt_created AS \"time\",\n temp AS \"Temperature\",\n (temp - ((100 - humidity)/5)) AS \"Dew Point\"\nFROM particle_photon\nORDER BY dt_created;",
"refId": "A",
"select": [
[
{
"params": [
"temp"
],
"type": "column"
}
],
[
{
"params": [
"humidity"
],
"type": "column"
}
]
],
"table": "particle_photon",
"timeColumn": "dt_created",
"timeColumnType": "timestamp",
"where": []
},
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select time , \ntemp_f , \n(((-42.379 + 2.04901523 * temp_f + 10.14333127*humidity - .22475541* temp_f * humidity - .00683783 * temp_f* temp_f - .05481717*humidity*humidity + .00122874 * temp_f * temp_f*humidity + .00085282 * temp_f*humidity*humidity - .00000199 * temp_f * temp_f*humidity*humidity)- 32)*.5556) AS \"Feels Like\" \nfrom \n (select dt_created as \"time\", humidity, ((temp* 1.8) + 32) AS temp_f \n from particle_photon \norder by dt_created) as t1 ;",
"refId": "B",
"select": [
[
{
"params": [
"id"
],
"type": "column"
}
]
],
"table": "particle_photon",
"timeColumn": "dt_created",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Bedroom",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "farenheit",
"label": "Temperature in F",
"logBase": 1,
"max": null,
"min": null,
"show": false
},
{
"format": "celsius",
"label": "Temperature",
"logBase": 1,
"max": "30",
"min": "10",
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": true,
"dashLength": 10,
"dashes": false,
"datasource": "MySQLRockPro",
"description": "Bedroom Humidity",
"fill": 1,
"fillGradient": 5,
"gridPos": {
"h": 6,
"w": 24,
"x": 0,
"y": 24
},
"hiddenSeries": false,
"id": 6,
"legend": {
"alignAsTable": false,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 0,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": false,
"rawSql": "SELECT\n dt_created AS \"time\",\n humidity AS \"Humidity\"\nFROM particle_photon\nWHERE\n $__timeFilter(dt_created)\nORDER BY dt_created",
"refId": "A",
"select": [
[
{
"params": [
"humidity"
],
"type": "column"
}
]
],
"table": "particle_photon",
"timeColumn": "dt_created",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Bedroom",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "percent",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "percent",
"label": "Humidity",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": true,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": true,
"dashLength": 10,
"dashes": false,
"datasource": "MySQLRockPro",
"description": "living room Humidity",
"fill": 1,
"fillGradient": 5,
"gridPos": {
"h": 6,
"w": 24,
"x": 0,
"y": 30
},
"hiddenSeries": false,
"id": 9,
"legend": {
"alignAsTable": false,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 0,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": false,
"rawSql": "SELECT\n dt_created AS \"time\",\n humidity\nFROM dht11_drawing_room\nWHERE\n $__timeFilter(dt_created)\nORDER BY dt_created",
"refId": "A",
"select": [
[
{
"params": [
"humidity"
],
"type": "column"
}
]
],
"table": "dht11_drawing_room",
"timeColumn": "dt_created",
"timeColumnType": "datetime",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Living Room",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "percent",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "percent",
"label": "Humidity",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": true,
"alignLevel": null
}
},
{
"aliasColors": {
"temperature": "rgb(96, 157, 252)"
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "MySQLRockPro",
"description": "Living Room Window side temperature.",
"fill": 3,
"fillGradient": 4,
"gridPos": {
"h": 6,
"w": 24,
"x": 0,
"y": 36
},
"hiddenSeries": false,
"id": 8,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": null,
"sortDesc": null,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "temperature",
"legend": true,
"yaxis": 2
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n dt_created AS \"time\",\n temperature\nFROM bmp180_drawing_room\nWHERE\n $__timeFilter(dt_created)\nORDER BY dt_created",
"refId": "A",
"select": [
[
{
"params": [
"temperature"
],
"type": "column"
}
],
[
{
"params": [
"pressure"
],
"type": "column"
}
]
],
"table": "bmp180_drawing_room",
"timeColumn": "dt_created",
"timeColumnType": "datetime",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Living Room",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
},
{
"format": "celsius",
"label": "Temperature",
"logBase": 1,
"max": "35",
"min": "10",
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"refresh": "30s",
"schemaVersion": 22,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-24h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "browser",
"title": "London Home",
"uid": "pqFsuS0Zk",
"version": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment