Skip to content

overview chart

김은호 프로 edited this page May 2, 2024 · 1 revision
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- 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": 1,
  "id": 138,
  "links": [],
  "liveNow": true,
  "panels": [
    {
      "datasource": {
        "type": "datasource",
        "uid": "-- Mixed --"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Active"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "dark-purple",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "InActive"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "text",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "firing"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "semi-dark-red",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 0,
        "y": 0
      },
      "id": 107,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": false
      },
      "pluginVersion": "9.4.7",
      "targets": [
        {
          "alias": "Active",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "orderByTime": "ASC",
          "policy": "default",
          "query": "SELECT sum(alive) as Active FROM (SELECT last(is_up) as alive FROM instance_up WHERE cluster_name =~ /^$clustername$/ AND $timeFilter GROUP BY cluster_name)",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "Alert",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": true,
          "orderByTime": "ASC",
          "policy": "default",
          "query": "select count(\"ip\") as Alert from\n( select last(\"threshold_cpu_util\") + last(\"threshold_mem_usage\") as health\nFROM \"db_health\" where $timeFilter group by dbname\n) where health > 0",
          "rawQuery": true,
          "refId": "D",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "InActive",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "hide": false,
          "query": "SELECT $registers-sum(alive) as InActive FROM (SELECT last(is_up) as alive FROM instance_up WHERE cluster_name =~ /^$clustername$/ AND $timeFilter GROUP BY cluster_name)",
          "rawQuery": true,
          "refId": "C",
          "resultFormat": "time_series"
        },
        {
          "datasource": {
            "type": "postgres",
            "uid": "2"
          },
          "editorMode": "code",
          "format": "table",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT\r\n    COUNT(DISTINCT label_value) as firing\r\nFROM\r\n    (\r\n        SELECT\r\n            current_state,\r\n            current_state_since,\r\n            last_eval_time,\r\n            current_state_end,\r\n            current_reason,\r\n            (json_array_elements(labels::json)->>0) as label_key,\r\n            (json_array_elements(labels::json)->>1) as label_value\r\n        FROM\r\n            alert_instance\r\n    ) AS subquery\r\nWHERE\r\n    current_state = 'Alerting' and label_key='dbname';",
          "refId": "B",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Summary",
      "transformations": [],
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<Click> on a point in the graph, then go to the <font color=\"#00ccff\">single cluster</font> and <font color=\"#00ccff\">session work load</font> panel for the current time range.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 3,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 1,
          "links": [],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "load_5"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "#BA43A9",
                  "mode": "fixed"
                }
              },
              {
                "id": "links",
                "value": []
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "avg_query_runtime"
            },
            "properties": [
              {
                "id": "unit",
                "value": "ms"
              },
              {
                "id": "custom.axisPlacement",
                "value": "hidden"
              },
              {
                "id": "links",
                "value": []
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "links",
                "value": []
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "[${__series.name}] Go to Single cluster.",
                    "url": "/d/experdb-single-cluster/experdb-single-cluster?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__field.labels.dbname}&${__url_time_range}&refresh=30s"
                  },
                  {
                    "title": "[${__series.name}] Go to Session workload.",
                    "url": "/d/experdb-session-workload/session-workload?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__field.labels.dbname}&${__url_time_range}&refresh=10s"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 0
      },
      "id": 6,
      "interval": "5m",
      "links": [],
      "maxDataPoints": 1702,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "8.5.1",
      "targets": [
        {
          "alias": "$tag_dbname",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "hide": false,
          "query": "SELECT mean(\"cpu_utilization\") AS \"load_average\"\nFROM \"psutil_cpu\"\nWHERE $timeFilter AND \"dbname\" =~ /^$clustername$/\nGROUP BY time($agg_interval), \"dbname\" fill(null)",
          "rawQuery": true,
          "refId": "B",
          "resultFormat": "time_series"
        }
      ],
      "title": "CPU load",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<Click> on a point in the graph, then go to the <font color=\"#00ccff\">single cluster</font> panel for the current time range.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisGridShow": true,
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": -1,
            "drawStyle": "line",
            "fillOpacity": 3,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "max": 100,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "[${__series.name}] Go to Single cluster.",
                    "url": "/d/experdb-single-cluster/experdb-single-cluster?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__field.labels.dbname}&${__url_time_range}&refresh=30s"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 0
      },
      "id": 8,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.0.7",
      "targets": [
        {
          "alias": "$tag_dbname",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "orderByTime": "ASC",
          "policy": "default",
          "query": "--SELECT dbname as memtop, top(value, $Top) as mem from (\nSELECT dbname, max(percent) as value FROM \"psutil_mem\" \nWHERE  $timeFilter AND dbname =~ /^$clustername$/\nGROUP BY time($agg_interval), dbname fill(none)\n--)",
          "rawQuery": true,
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "title": "Memory Usage",
      "transformations": [
        {
          "id": "sortBy",
          "options": {
            "fields": {},
            "sort": [
              {
                "desc": false,
                "field": "mem"
              }
            ]
          }
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "read_bytes"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "dark-blue",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "write_bytes"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "dark-yellow",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "read_bytes(172.31.4.212)"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "orange",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "read_bytes(172.31.4.211)"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "blue",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "write_bytes(172.31.4.211)"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "green",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "write_bytes(172.31.4.212)"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "yellow",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 0
      },
      "id": 37,
      "interval": "2m",
      "links": [],
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.0.7",
      "targets": [
        {
          "alias": "$tag_dbname",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "hide": false,
          "query": "SELECT \n    non_negative_derivative(max(\"read_bytes\"), $__interval) + non_negative_derivative(max(\"write_bytes\"), $__interval) \nFROM \n    \"psutil_disk_io_total\" \nWHERE  \n    $timeFilter \n    AND dbname =~ /^$clustername$/ \nGROUP BY \n    dbname, time($agg_interval) \nFILL(none)",
          "rawQuery": true,
          "refId": "C",
          "resultFormat": "time_series"
        }
      ],
      "title": "Disk I/O Totals",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "postgres",
        "uid": "2"
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 6,
        "x": 0,
        "y": 5
      },
      "id": 121,
      "options": {
        "afterRender": "",
        "content": "{{#each data}}\r\n<div style=\"font-size:110%; margin-left:25px;\" >{{alertname}}</div>\r\n{{#if (contains alertname \"dead_lock\")}}\r\n<strong onclick=\"location.href='/d/experdb-wait-analysis/2-2-wait-analysis?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-top_queries=10'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Wait analysis.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"swap_usage\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"table_bloat\")}}\r\n<strong onclick=\"location.href='/d/experdb-table-overview/4-2-table-overview?orgId=1&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=10'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Table overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"txid_max_age\")}}\r\n<strong onclick=\"location.href='/d/experdb-table-overview/4-2-table-overview?orgId=1&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=10'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Table overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"inact_slot\")}}\r\n<strong onclick=\"location.href='/d/experdb-replication-state/5-2-replication-state?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-blank='\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Table overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"longrun_sql\")}}\r\n<strong onclick=\"location.href='/d/experdb-session-workload/2-1-session-workload?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-top_queries=10&var-time=%7B%7B$timeFilter%7D%7D'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Session workload.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"invalid_index\")}}\r\n<strong onclick=\"location.href='/d/experdb-index-overview/4-1-index-overview?orgId=1&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=20'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Index overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"buffer_hitratio\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"duplication_index\")}}\r\n<strong onclick=\"location.href='/d/experdb-index-overview/4-1-index-overview?orgId=1&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=20'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Index overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"idle_in_txn\")}}\r\n<strong onclick=\"location.href='/d/experdb-wait-analysis/2-2-wait-analysis?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-top_queries=10'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Wait analysis.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"commit_ratio\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"lock_count\")}}\r\n<strong onclick=\"location.href='/d/experdb-wait-analysis/2-2-wait-analysis?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-top_queries=10'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Wait analysis.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"sessions\")}}\r\n<strong onclick=\"location.href='/d/experdb-session-workload/2-1-session-workload?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-top_queries=10&var-time=%7B%7B$timeFilter%7D%7D'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Session workload.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"query_runtime\")}}\r\n<strong onclick=\"location.href='/d/experdb-statements-statistics/3-2-statements-statistics?orgId=1&refresh=1m&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=10&var-calls_q=All&var-runtime_q=All&var-agg_interval=5m'\"\r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Statements statistics.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"cpu_util\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"disk_usage\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"mem_usage\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"replication_delay\")}}\r\n<strong onclick=\"location.href='/d/experdb-replication-state/5-2-replication-state?orgId=1&refresh=10s&var-clustername={{dbname}}&var-dbname={{dbname}}&var-agg_interval=10s&var-blank='\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Table overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"unused_index\")}}\r\n<strong onclick=\"location.href='/d/experdb-index-overview/4-1-index-overview?orgId=1&var-clustername={{dbname}}&var-dbname={{dbname}}&var-top=20'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Index overview.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (contains alertname \"wal_size\")}}\r\n<strong onclick=\"location.href='/d/experdb-single-cluster/1-2-single-cluster?orgId=1&var-clustername={{dbname}}&refresh=30s&var-dbname={{dbname}}&var-agg_interval=1m'\" \r\nstyle=\"margin-right:5%; float: right; cursor: pointer; text-decoration: underline;\" title='[{{dbname}}] Go to Single cluster.'><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-ln3h1p\"><path fill=\"#ccccdc\" d=\"M10,17.55,8.23,19.27a2.47,2.47,0,0,1-3.5-3.5l4.54-4.55a2.46,2.46,0,0,1,3.39-.09l.12.1a1,1,0,0,0,1.4-1.43A2.75,2.75,0,0,0,14,9.59a4.46,4.46,0,0,0-6.09.22L3.31,14.36a4.48,4.48,0,0,0,6.33,6.33L11.37,19A1,1,0,0,0,10,17.55ZM20.69,3.31a4.49,4.49,0,0,0-6.33,0L12.63,5A1,1,0,0,0,14,6.45l1.73-1.72a2.47,2.47,0,0,1,3.5,3.5l-4.54,4.55a2.46,2.46,0,0,1-3.39.09l-.12-.1a1,1,0,0,0-1.4,1.43,2.75,2.75,0,0,0,.23.21,4.47,4.47,0,0,0,6.09-.22l4.55-4.55A4.49,4.49,0,0,0,20.69,3.31Z\"></path></svg></strong>\r\n{{/if}}\r\n{{#if (eq state \"Pending\")}}\r\n<div style=\"color:#f5b73d;\">\r\n  <svg xmlns=\"http://www.w3.org/2000/svg\" data-name=\"Layer 1\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-14jc7gd\"><path fill=\"#f5b73d\" d=\"M18.9917,21.002h-1V19.335a5.00057,5.00057,0,0,0-.29956-1.67773c-.01093-.02936-.0224-.05658-.03589-.08454a4.97694,4.97694,0,0,0-.66455-1.23675l-1.3999-1.86719a3.01933,3.01933,0,0,1-.6001-1.80078V11.6582a3.02108,3.02108,0,0,1,.87842-2.12109l.65722-.65723A4.94566,4.94566,0,0,0,17.92365,6.0415c.00054-.01391.008-.02551.008-.03955l-.00281-.01373a5.01836,5.01836,0,0,0,.06287-.64349V3.002h1a1,1,0,0,0,0-2h-14a1,1,0,0,0,0,2h1V5.34473a5.01836,5.01836,0,0,0,.06287.64349L6.05176,6.002c0,.014.00744.02564.008.03955a4.94571,4.94571,0,0,0,1.3963,2.83838l.65723.65723A3.02108,3.02108,0,0,1,8.9917,11.6582V12.668a3.02212,3.02212,0,0,1-.59961,1.80078L6.99121,16.33594a4.98221,4.98221,0,0,0-.66437,1.23718c-.0133.02771-.02472.05463-.03552.08368A5.00309,5.00309,0,0,0,5.9917,19.335v1.667h-1a1,1,0,0,0,0,2h14a1,1,0,0,0,0-2Zm-11-16v-2h8v2Zm.87842,2.46387A2.97036,2.97036,0,0,1,8.49323,7.002h6.99694a2.97094,2.97094,0,0,1-.37689.46387l-.65723.65723a4.9603,4.9603,0,0,0-1.42187,2.8789h-2.085A4.96025,4.96025,0,0,0,9.52734,8.123ZM9.99219,15.668a5.03688,5.03688,0,0,0,.98828-2.666h2.02246a5.03332,5.03332,0,0,0,.98877,2.666l1.00012,1.334H8.99133Zm5.99951,5.334h-8V19.335a2.954,2.954,0,0,1,.02722-.333h7.94556a2.954,2.954,0,0,1,.02722.333Z\"></path></svg>\r\n  <div style=\"display: inline; margin-left:5px;\">Pending</div>\r\n</div>\r\n{{!-- <button id=\"arrow{{@index}}\" style=\"background-color: transparent; border: none; margin-left:20px;\" onmouseover=\"toggleTable('{{@index}}', true)\" onmouseout=\"toggleTable('{{@index}}', false)\" >▶ 1 instance</button> --}}\r\n<div>&nbsp;</div>\r\n{{else}}\r\n{{#if (eq state \"Alerting\")}}\r\n<div style=\"color:#d10e5c\">\r\n  <svg  xmlns=\"http://www.w3.org/2000/svg\" data-name=\"Layer 1\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" class=\"css-1xud2co\"><path fill=\"#d10e5c\" d=\"M8.46777,8.39453l-.00225.00183-.00214.00208ZM18.42188,8.208a1.237,1.237,0,0,0-.23-.17481.99959.99959,0,0,0-1.39941.41114,5.78155,5.78155,0,0,1-1.398,1.77734,8.6636,8.6636,0,0,0,.1333-1.50977,8.71407,8.71407,0,0,0-4.40039-7.582,1.00009,1.00009,0,0,0-1.49121.80567A7.017,7.017,0,0,1,7.165,6.87793l-.23047.1875a8.51269,8.51269,0,0,0-1.9873,1.8623A8.98348,8.98348,0,0,0,8.60254,22.83594.99942.99942,0,0,0,9.98,21.91016a1.04987,1.04987,0,0,0-.0498-.3125,6.977,6.977,0,0,1-.18995-2.58106,9.004,9.004,0,0,0,4.3125,4.0166.997.997,0,0,0,.71534.03809A8.99474,8.99474,0,0,0,18.42188,8.208ZM14.51709,21.03906a6.964,6.964,0,0,1-3.57666-4.40234,8.90781,8.90781,0,0,1-.17969-.96387,1.00025,1.00025,0,0,0-.79931-.84473A.982.982,0,0,0,9.77,14.80957a.99955.99955,0,0,0-.8667.501,8.9586,8.9586,0,0,0-1.20557,4.71777,6.98547,6.98547,0,0,1-1.17529-9.86816,6.55463,6.55463,0,0,1,1.562-1.458.74507.74507,0,0,0,.07422-.05469s.29669-.24548.30683-.2511a8.96766,8.96766,0,0,0,2.89874-4.63269,6.73625,6.73625,0,0,1,1.38623,8.08789,1.00024,1.00024,0,0,0,1.18359,1.418,7.85568,7.85568,0,0,0,3.86231-2.6875,7.00072,7.00072,0,0,1-3.2793,10.457Z\"></path></svg>\r\n  <div style=\"display: inline; margin-left:5px;\">Firing </div>\r\n  <div style=\"color:#ccccdc; display: inline;\"> for {{time_difference}}</div>\r\n</div>\r\n<button id=\"arrow{{@index}}\" style=\"background-color: transparent; border: none; margin-left:20px;\" onmouseover=\"toggleTable('{{@index}}', true)\" onmouseout=\"toggleTable('{{@index}}', false)\" >▶ 1 instance</button>\r\n{{/if}}\r\n<div id=\"alertTable{{@index}}\" style=\"display: none; margin-left:15px;\" onmouseover=\"toggleTable('{{@index}}', true)\" onmouseout=\"toggleTable('{{@index}}', false)\">\r\n  <table border=\"1\" style=\"width:60%; margin-left:5%;\">\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">State</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%; color:#d10e5c\">{{state}}</td>\r\n    </tr>\r\n    {{!-- <tr style=\"font-size:90%; text-align: left; height: 10%;\">\r\n      <td style=\"font-size:97%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">Time elapsed</td>\r\n      <td style=\"font-size:97%; text-align: left; height: 10%;\">{{time_difference}}</td>\r\n    </tr> --}}\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">Created</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%;\">{{converted_current_state_since}}</td>\r\n    </tr>\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">Dbname</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%;\">{{dbname}}</td>\r\n    </tr>\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">IP</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%;\">{{ip}}</td>\r\n    </tr>\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">Alert Value</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%;\">\r\n        {{#if (startsWith alertname \"cpu_\")}}\r\n          <strong id=\"alertValue\">{{data}} %</strong>\r\n        {{else}}\r\n          {{#if (startsWith alertname \"disk_\")}}\r\n            <strong id=\"alertValue\">{{data}} %</strong>  \r\n          {{else}}\r\n            {{#if (startsWith alertname \"mem_\")}}\r\n              <strong id=\"alertValue\">{{data}} %</strong>\r\n            {{else}}\r\n              {{#if (startsWith alertname \"swap_\")}}\r\n              <strong id=\"alertValue\">{{data}} %</strong>\r\n              {{else}}\r\n                {{#if (startsWith alertname \"sessions\")}}\r\n                <strong id=\"alertValue\">{{data}} %</strong>\r\n                {{else}}\r\n                  {{#if (startsWith alertname \"commit_ratio\")}}\r\n                  <strong id=\"alertValue\">{{data}} %</strong>\r\n                  {{else}}\r\n                    {{#if (startsWith alertname \"buffer_hitratio\")}}\r\n                    <strong id=\"alertValue\">{{data}} %</strong>\r\n                    {{else}}\r\n                      {{#if (startsWith alertname \"txid_\")}}\r\n                      <strong id=\"alertValue\">{{data}} %</strong>\r\n                      {{else}}\r\n                        {{#if (startsWith alertname \"table_bloat\")}}\r\n                        <strong id=\"alertValue\">{{data}} %</strong>\r\n                        {{else}}\r\n                          {{#if (startsWith alertname \"wal_size\")}}\r\n                          <strong id=\"alertValue\">{{volConvert data}}</strong>\r\n                          {{else}}\r\n                            {{#if (startsWith alertname \"replication_delay\")}}\r\n                            <strong id=\"alertValue\">{{data}} GB</strong>\r\n                            {{else}}\r\n                              {{#if (startsWith alertname \"longrun_sql\")}}\r\n                              <strong id=\"alertValue\">{{data}} Sec</strong>\r\n                              {{else}}\r\n                                {{#if (startsWith alertname \"query_\")}}\r\n                                <strong id=\"alertValue\">{{data}} Sec</strong>\r\n                                {{else}}\r\n                                  {{#if (startsWith alertname \"lock_count\")}}\r\n                                  <strong id=\"alertValue\">{{data}}</strong>\r\n                                  {{else}}\r\n                                    {{#if (startsWith alertname \"idle_in_txn\")}}\r\n                                    <strong id=\"alertValue\">{{data}}</strong>\r\n                                    {{else}}\r\n                                      {{#if (startsWith alertname \"dead_lock\")}}\r\n                                      <strong id=\"alertValue\">{{data}}</strong>\r\n                                      {{else}}\r\n                                        {{#if (startsWith alertname \"inact_slot\")}}\r\n                                        <strong id=\"alertValue\">{{data}}</strong>\r\n                                        {{else}}\r\n                                          {{#if (startsWith alertname \"unused_index\")}}\r\n                                          <strong id=\"alertValue\">{{data}}</strong>\r\n                                          {{else}}\r\n                                            {{#if (startsWith alertname \"invalid_index\")}}\r\n                                            <strong id=\"alertValue\">{{data}}</strong>\r\n                                            {{else}}\r\n                                              {{#if (startsWith alertname \"duplication_index\")}}\r\n                                              <strong id=\"alertValue\">{{data}}</strong>\r\n                                              {{/if}}\r\n                                            {{/if}}\r\n                                          {{/if}}\r\n                                        {{/if}}\r\n                                      {{/if}}\r\n                                    {{/if}}\r\n                                  {{/if}}\r\n                                {{/if}}\r\n                              {{/if}}\r\n                            {{/if}}\r\n                          {{/if}}\r\n                        {{/if}}\r\n                      {{/if}}\r\n                    {{/if}}\r\n                  {{/if}}\r\n                {{/if}}\r\n              {{/if}}\r\n            {{/if}}\r\n          {{/if}}\r\n        {{/if}}\r\n      </td>\r\n    </tr>\r\n    <tr>\r\n      <td style=\"font-size:90%; font-weight: bold; text-align: left; background-color:rgb(34, 37, 43);\">Threshold</td>\r\n      <td style=\"font-size:90%; text-align: left; height: 10%;\">{{threshold}}</td>\r\n    </tr>\r\n  </table>\r\n</div>\r\n{{/if}}\r\n<div class=\"horizontal-line\"></div>\r\n{{/each}}",
        "defaultContent": "<div style=\"text-align:center; margin-top:35%;\">No alerts matching filters<div>",
        "editor": {
          "format": "auto",
          "height": 487,
          "language": "handlebars"
        },
        "editors": [
          "helpers",
          "styles"
        ],
        "externalScripts": [],
        "externalStyles": [],
        "helpers": "toggleTable = (index, isMouseOver) => {\r\n  let table = document.getElementById(\"alertTable\" + index);\r\n  let tableValue = table.getAttribute(\"data-value\");\r\n  let arrow = document.getElementById(\"arrow\" + index);\r\n  if (isMouseOver) {\r\n    table.style.display = \"block\";\r\n    arrow.innerHTML = \"▼ 1 instance\";\r\n  } else {\r\n    table.style.display = \"none\";\r\n    arrow.innerHTML = \"▶ 1 instance\";\r\n  }\r\n  return true;\r\n}\r\n\r\n//wal_size Byte기준 용량 Convert\r\nhandlebars.registerHelper('volConvert', (wal_size) => {\r\n  if (wal_size < 1024) {\r\n    return wal_size + \" bytes\";\r\n  } else if (wal_size < 1024 * 1024) {\r\n    return (wal_size / 1024).toFixed(2) + \" KB\";\r\n  } else if (wal_size < 1024 * 1024 * 1024) {\r\n    return (wal_size / (1024 * 1024)).toFixed(2) + \" MB\";\r\n  } else {\r\n    return (wal_size / (1024 * 1024 * 1024)).toFixed(2) + \" GB\";\r\n  }\r\n});\r\n",
        "renderMode": "allRows",
        "styles": "tr td:nth-child(1),\r\ntr td:nth-child(2),\r\ntr td:nth-child(3),\r\ntr td:nth-child(5) {\r\n  white-space: nowrap;\r\n}\r\n\r\n.horizontal-line {\r\n  border-bottom: 0.1px solid #0a0a0a;\r\n  margin-top: 10px;\r\n  margin-bottom: 5px;\r\n\r\n  /* 선 아래 여백을 설정할 수 있습니다. */\r\n}\r\n\r\n\r\nstrong,\r\nbutton {\r\n  transition: transform 0.3s ease-in-out;\r\n  display: inline-block;\r\n}\r\n\r\n#alertValue {\r\n  color: #d10e5c;\r\n}\r\n\r\nstrong:hover,\r\nbutton:hover {\r\n  transform: scale(1.2);\r\n}",
        "wrap": false
      },
      "pluginVersion": "4.5.0",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "2"
          },
          "editorMode": "code",
          "format": "table",
          "hide": false,
          "rawQuery": true,
          "rawSql": "select * from (\r\nWITH query1 AS (\r\n    SELECT\r\n        rule_uid,\r\n        current_state as state,\r\n        TO_CHAR(TO_TIMESTAMP(current_state_since), 'YYYY-MM-DD HH24:MI:SS') as converted_current_state_since,\r\n        last_eval_time,\r\n        TO_CHAR(TO_TIMESTAMP(current_state_end), 'YYYY-MM-DD HH24:MI:SS') as current_state_end,\r\n        current_reason,\r\n        EXTRACT(DAY FROM AGE(TO_TIMESTAMP(current_state_end), TO_TIMESTAMP(current_state_since))) || 'd ' ||\r\n        TO_CHAR(AGE(TO_TIMESTAMP(current_state_end), TO_TIMESTAMP(current_state_since)), 'HH24h MIm SSs') as time_difference,\r\n--        MAX(CASE WHEN label_key = '__alert_rule_namespace_uid__' THEN label_value END) as alert_rule_namespace_uid,\r\n--        MAX(CASE WHEN label_key = '__alert_rule_uid__' THEN label_value END) as alert_rule_uid,\r\n        MAX(CASE WHEN label_key = 'alertname' THEN label_value END) as alertname,\r\n        MAX(CASE WHEN label_key = 'dbname' THEN label_value END) as dbname,\r\n--        MAX(CASE WHEN label_key = 'grafana_folder' THEN label_value END) as grafana_folder,\r\n        MAX(CASE WHEN label_key = 'ip' THEN label_value END) as ip,\r\n        MAX(CASE WHEN label_key = 'threshold' THEN label_value END) as threshold\r\n    FROM (\r\n        SELECT\r\n            rule_uid,\r\n            (json_array_elements(labels::json)->>0) as label_key,\r\n            (json_array_elements(labels::json)->>1) as label_value,\r\n            current_state,\r\n            current_state_since,\r\n            last_eval_time,\r\n            current_state_end,\r\n            current_reason\r\n        FROM\r\n            alert_instance\r\n        WHERE\r\n            current_state != 'Normal'\r\n    ) subquery\r\n    GROUP BY\r\n        rule_uid,current_state, current_state_since, last_eval_time, current_state_end, current_reason\r\n),\r\nquery2 AS (\r\n    SELECT\r\n    sub.alertname,\r\n    sub.dbname,\r\n    sub.grafana_folder,\r\n    sub.ip,\r\n    sub.data\r\nFROM (\r\n    SELECT DISTINCT ON (alertname)\r\n        split_part(split_part(text, ',', 1), '=', 2) AS alertname,\r\n        split_part(split_part(text, ',', 2), '=', 2) AS dbname,\r\n        split_part(split_part(text, ',', 3), '=', 2) AS grafana_folder,\r\n        split_part(split_part(text, ',', 4), '=', 2) AS ip,\r\n        round((data::json->'values'->>'B')::numeric,1) AS data\r\n    FROM annotation\r\n    WHERE new_state = 'Alerting'\r\n    ORDER BY alertname, data DESC\r\n) AS sub\r\nORDER BY sub.alertname, sub.data DESC\r\n)\r\nSELECT \r\n\tquery1.rule_uid,\r\n    query1.state,\r\n    query1.converted_current_state_since,\r\n    query1.last_eval_time,\r\n    query1.current_state_end,\r\n    query1.current_reason,\r\n    query1.time_difference,\r\n    query1.alertname,\r\n    query1.dbname,\r\n    query1.ip,\r\n    query1.threshold,\r\n    query2.data\r\nFROM query1\r\ninner JOIN query2\r\nON query1.alertname = query2.alertname\r\nORDER BY converted_current_state_since DESC, alertname, state DESC, rule_uid DESC\r\n) q\r\nwhere dbname in ($clustername)",
          "refId": "B",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Alert list",
      "transformations": [],
      "type": "marcusolsson-dynamictext-panel"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<Click> on the graph and then go to the <font color=\"#00ccff\">table overview</font> panel for the current time range.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [
            {
              "title": "[${__series.name}] Go to table overview.",
              "url": "/d/experdb-table-overview/experdb-table-overview?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__series.name}&${Top:queryparam}&${__url_time_range}"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 5
      },
      "id": 104,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.4.7",
      "targets": [
        {
          "$$hashKey": "object:24",
          "aggregation": "Last",
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "decimals": 2,
          "displayAliasType": "Warning / Critical",
          "displayType": "Regular",
          "displayValueWithAlias": "Never",
          "hide": false,
          "query": "SELECT sum(tupread) as LogicalRead\nFROM (\nselect time, non_negative_derivative(mean(\"tup_fetched\"), $agg_interval) + non_negative_derivative(mean(\"tup_returned\"), $agg_interval) AS tupread\n    FROM db_stats\n    WHERE $timeFilter AND dbname =~ /^$clustername$/\n    group by time($agg_interval), cluster_name, dbname\n) GROUP BY time($agg_interval), cluster_name",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "units": "none",
          "valueHandler": "Number Threshold"
        }
      ],
      "title": "Logical Read",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<Click> on the graph and then go to the <font color=\"#00ccff\">table overview</font> panel for the current time range.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [
            {
              "title": "[${__series.name}] Go to table overview.",
              "url": "/d/experdb-table-overview/experdb-table-overview?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__series.name}&${Top:queryparam}&${__url_time_range}"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 5
      },
      "id": 13,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.4.7",
      "targets": [
        {
          "$$hashKey": "object:24",
          "aggregation": "Last",
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "decimals": 2,
          "displayAliasType": "Warning / Critical",
          "displayType": "Regular",
          "displayValueWithAlias": "Never",
          "hide": false,
          "query": "/* SELECT sum(inserted) as inserted, sum(updated) as updated, sum(deleted) as deleted\nFROM (\n SELECT\n      spread(tup_inserted) AS inserted,\n      spread(tup_updated) AS updated,\n      spread(tup_deleted) AS deleted\n    FROM db_stats\n    WHERE $timeFilter AND dbname =~ /^$clustername$/\n    AND cluster_name =~/^$logicaliotop$/\n    group by dbname\n)\nGROUP BY cluster_name*/\nSELECT sum(tupwrite) as LogicalWrite\nFROM (\nselect time, non_negative_derivative(mean(\"tup_inserted\"), $agg_interval) + non_negative_derivative(mean(\"tup_updated\"), $agg_interval)+ non_negative_derivative(mean(\"tup_deleted\"), $agg_interval) AS tupwrite\n    FROM db_stats\n    WHERE $timeFilter AND dbname =~ /^$clustername$/\n    group by time($agg_interval), cluster_name, dbname\n) GROUP BY time($agg_interval), cluster_name",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "units": "none",
          "valueHandler": "Number Threshold"
        }
      ],
      "title": "Logical Write",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [
            {
              "title": "[${__data.fields.cluster_name}] Go to table overview.",
              "url": "/d/experdb-table-overview/experdb-table-overview?orgId=1&var-group=${group}&var-clsutername=${__data.fields.cluster_name}&${Top:queryparam}&${__url_time_range}"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 5
      },
      "id": 109,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.4.7",
      "targets": [
        {
          "$$hashKey": "object:24",
          "aggregation": "Last",
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "decimals": 2,
          "displayAliasType": "Warning / Critical",
          "displayType": "Regular",
          "displayValueWithAlias": "Never",
          "hide": false,
          "query": "SELECT sum(blks_read) as PhysicalRead\nFROM (\nselect time, non_negative_derivative(mean(\"blks_read\"), $agg_interval) AS blks_read\n    FROM db_stats\n    WHERE $timeFilter\n    AND cluster_name =~/^$clustername$/\n    group by time($agg_interval), cluster_name, dbname\n) GROUP BY time($agg_interval), cluster_name",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "units": "none",
          "valueHandler": "Number Threshold"
        }
      ],
      "title": "Physical Read",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<Click> on a point in the graph, then go to the <font color=\"#00ccff\">session work load</font> panel for the current time range.\n",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 3,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [
            {
              "title": "[${__series.name}] Go to Session workload.",
              "url": "/d/experdb-session-workload/session-workload??orgId=1&var-group=${group}&var-clustername=${__series.name}&${__url_time_range}&refresh=10s"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 10
      },
      "id": 20,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "targets": [
        {
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "hide": false,
          "query": "SELECT sum(active) as active FROM  (\nSELECT last(active) as active\nFROM backends where $timeFilter\nAND  \"cluster_name\"  =~ /^$clustername$/ \nGROUP BY time($agg_interval), cluster_name, dbname\n) GROUP BY time($agg_interval), cluster_name",
          "rawQuery": true,
          "refId": "D",
          "resultFormat": "time_series"
        },
        {
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "hide": false,
          "query": "select \nmax(\"active\")\nFROM\n(\nSELECT\n (\"active\") \nFROM backends where\n$timeFilter AND dbname =~ /^$clustername$/\n) \nGROUP BY  cluster_name, time($agg_interval) fill(0)\n/*\nSELECT last(\"active\") FROM backends where $timeFilter AND  \"cluster_name\" =~/^$sessiontop$/ GROUP BY  cluster_name, time($agg_interval) fill(0)*/",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series"
        }
      ],
      "title": "Active Sessions ",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<p>The information collected from pg_stat_database is used to display the number of transactions per second. \nIt represents \"(xact_commit+xact_rollback)/sec\". \nNB! This index includes all executed queries, including Read transaction. There may be a numerical difference with the transaction statistics from the application.<p>\n",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "line"
            }
          },
          "links": [
            {
              "title": "[${__series.name}] Go to Single cluster.",
              "url": "/d/experdb-single-cluster/experdb-single-cluster?orgId=1&var-group=${group}&var-clustername=${__series.name}&var-dbname=${__field.labels.dbname}&${__url_time_range}&refresh=30s"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Temp bytes written"
            },
            "properties": [
              {
                "id": "unit",
                "value": "Bps"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 10
      },
      "id": 89,
      "interval": "5m",
      "links": [],
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "8.5.1",
      "targets": [
        {
          "$$hashKey": "object:76",
          "aggregation": "Last",
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "decimals": 2,
          "displayAliasType": "Warning / Critical",
          "displayType": "Regular",
          "displayValueWithAlias": "Never",
          "hide": false,
          "query": "SELECT sum(TPS) from (\nSELECT non_negative_derivative(max(\"xact_rollback\"), 1s) + non_negative_derivative(max(\"xact_commit\"), 1s) as \"TPS\" FROM \"db_stats\" WHERE $timeFilter AND cluster_name =~ /^$clustername$/ GROUP BY time(1m), cluster_name, dbname fill(none)\n) group by time($agg_interval), cluster_name  fill(none)",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "units": "none",
          "valueHandler": "Number Threshold"
        }
      ],
      "title": "TPS",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<p>The Replication replay lag measures the delay in the replication process between the current write-ahead log (WAL) location and the replay location of PostgreSQL. It reflects the time difference between when changes are written to the primary database's WAL and when they are replayed on the replica.</p>",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [
            {
              "title": "[${__series.name}]go to Replication state.",
              "url": "/d/experdb-replication-state/5-2-replication-state?orgId=1&var-group=${group}&refresh=10s&var-clustername=${__series.name}"
            }
          ],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "decbytes"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 10
      },
      "id": 113,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "alias": "$tag_cluster_name",
          "datasource": {
            "type": "influxdb",
            "uid": "0"
          },
          "query": "SELECT\ncluster_name,\nlast(\"replay_lag_b\") as \"lag\"\nFROM \"replication\"\n    WHERE $timeFilter\n AND cluster_name =~/^$clustername$/\nGROUP BY cluster_name,time($agg_interval) fill(none)",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series"
        }
      ],
      "title": "Replication replay lag",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "0"
      },
      "description": "<p>Clicking on the PID will take you to the [$clustername]'s <font color=\"#00ccff\"> session history</font> with the same time range.</p>",
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 24,
        "x": 0,
        "y": 15
      },
      "id": 123,
      "options": {
        "afterRender": "  const buttonsDiv = document.getElementById('buttons');\r\n\r\n\r\n  if(this.refreshed){\r\n    const selectAllCheckbox = document.getElementById('selectAll');\r\n    if(selectAllCheckbox){\r\n      //selectAllCheckbox.checked = this.allChecked;\r\n    }\r\n  }\r\n\r\n  if(buttonsDiv){\r\n     if (!this.checked && !this.refreshed){\r\n      if(this.timefilter.includes('now')){\r\n        buttonsDiv.style.display = 'block'; // show the buttons\r\n      }else{\r\n        buttonsDiv.style.display = 'none';  // hide the buttons\r\n      }\r\n    }else if (!this.checked) {\r\n    buttonsDiv.style.display = 'block'; // Show the buttons\r\n    }else if(this.checked && this.refreshed && this.timefilter && this.from){\r\n      const timestampRegex = /\\d+(?=ms)/g; // Match one or more digits followed by 'ms'\r\n      const matches = this.timefilter.match(timestampRegex);\r\n      if (matches && matches.length >= 2) {\r\n          const toTimestamp = (matches[0]);\r\n          if(toTimestamp == this.from){\r\n              buttonsDiv.style.display = 'block'; // Show the buttons\r\n              // Clear the existing rows in the tbody\r\n              const tbody = document.getElementById('tbody_overview'); \r\n              tbody.innerHTML = '';\r\n              // Iterate over each row in this.rows and append it to the tbody\r\n              this.rows.forEach(row => {\r\n                  tbody.appendChild(row.cloneNode(true));\r\n              });\r\n          }else{\r\n              buttonsDiv.style.display = 'none';  // hide the buttons\r\n          }\r\n      } \r\n    }else{\r\n      buttonsDiv.style.display = 'none';  // hide the buttons\r\n    }\r\n  }\r\n\r\n\r\n  \r\n  // Get all hidden query elements\r\n    const hiddenQueries = document.querySelectorAll('#query_hidden');\r\n\r\n   // console.log('Hidden queries count:', hiddenQueries.length);\r\n\r\n    // Loop through each hidden query element\r\n    hiddenQueries.forEach(hiddenQuery => {\r\n        // Get the full query from the hidden element's text content\r\n        const fullQuery = hiddenQuery.textContent.trim();\r\n\r\n        // Get the corresponding query cell\r\n        const queryCell = hiddenQuery.nextElementSibling;\r\n\r\n        // Set the full query as the title attribute of the query cell\r\n        if(fullQuery.length > 47){\r\n\t\t\t\t  queryCell.title = fullQuery;\r\n        }\r\n    });",
        "content": "<div>\n  <div id=\"buttons\" style=\"float:left; width:100%\">\n    <button class=\"kill-button\"  onclick=\"openConfirmationModal('{{variable \"‘${__user.login}’\"}}','{{variable \"__user.id\"}}','kill')\">Kill process</button>\n    <button class=\"cancel-button\"  onclick=\"openConfirmationModal('{{variable \"‘${__user.login}’\"}}','{{variable \"__user.id\"}}', 'cancel')\">Cancel Query</button>\n    {{#if (isRefresh (variable \"__to\"))}}\n    <button id=\"refresh\" class=\"custom-button\"  onclick=\"stopRefresh()\">Restart Refresh</button>\n    {{else}} \n    <button id=\"refresh\" class=\"custom-button\"  onclick=\"stopRefresh()\">Hold Refresh</button>\n    {{/if}}\n</div>\n<div>\n<table id=\"table_overview\" style=\"width: 12%; height: 110px;\">\n  <thead>\n    <tr>\n      <th style=\"width: 30px;\"><input type=\"checkbox\" id=\"selectAll\" onclick=\"selectAllRows()\"></th>\n      <th id=\"cluster_name\" style=\"min-width: 150px\" onclick=\"sortTable('cluster_name')\">cluster name</th>\n      <th id=\"dbname\" style=\"min-width: 150px\" class=\"sortable\" onclick=\"sortTable('dbname')\">dbname</th>\n      <th id=\"pid\"  style=\"min-width:100px\" class=\"sortable\" onclick=\"sortTable('pid')\">pid</th>\n      <th id=\"user\" style=\"min-width:150px\" onclick=\"sortTable('user')\">user</th>\n      <th id=\"state\" style=\"min-width:210px\" onclick=\"sortTable('state')\">state</th>      \n      <th id=\"duration\" style=\"min-width:100px\" onclick=\"sortTable('duration')\">duration</th>\n      <th id=\"query\" style=\"min-width: 380px\" onclick=\"sortTable('query')\">query</th>\n      <th id=\"queryid\" style=\"min-width: 200px\" onclick=\"sortTable('queryid')\">query id</th> \n      <th id=\"wait_event\" style=\"min-width:150px\" onclick=\"sortTable('wait_event')\">wait event</th>\n      <th id=\"appname\" style=\"min-width: 160px\" onclick=\"sortTable('appname')\">appname</th>\n      <th id=\"client_ip\" style=\"min-width: 180px\" onclick=\"sortTable('client_ip')\">client ip</th>\n      {{!-- <th id=\"blocking_pids\" style=\"min-width: 150px\" onclick=\"sortTable('blocking_pids')\">blocking pids</th> --}}\n      <th id=\"backend_start\" style=\"min-width: 200px\" class=\"sortable\" onclick=\"sortTable('backend_start')\">backend start</th>\n    </tr>\n  </thead>\n  <tbody id=\"tbody_overview\">\n    {{#each data}}\n    <tr>\n      <td style=\"width: 30px;\"><input type=\"checkbox\" class=\"rowCheckbox\" onClick=\"updateSelectAllCheckbox()\"></td>\n      <td  title=\"{{title cluster_name 15}}\"  data-column=\"cluster_name\"  style='color:#73BF69;min-width:150px;max-width:150px;'>{{reduce2 cluster_name}}</td>\n      <td  title=\"{{title dbname 15}}\"  data-column=\"dbname\"  style='color:#73BF69;max-width:150px;min-width:150px;'>{{reduce2 dbname}}</td>\n      <td data-column=\"pid\" style='color:#73BF69;min-width:100px;max-width:100px;'>\n\t\t\t  <a title=\"[pid : {{pid}}] Go to session history.\" \n\t\t\t   id=\"pid{{@index}}\" style='color:#73BF69;min-width:100px; max-width:100px;cursor: pointer; text-decoration: underline; ' onclick=\"goLink('pid', '{{pid}}', '{{cluster_name}}', '{{dbname}}')\">{{pid}}</a>\n\t\t\t</td>\n      <td title=\"{{title user 15}}\" data-column=\"user\"  style='color:#73BF69;min-width:150px;max-width:150px;'>\n        {{reduce2 user}}</td>\n      <td  data-column=\"state\"  style='color:#73BF69;min-width:210px;max-width:210px;'>\n        {{reduce3 state}}</td>\n      <td  data-column=\"duration\"  style='color:#73BF69;min-width:100px;max-width:100px;'>\n         {{#if (isNull duration)}}\n            0s\n          {{else}}\n             {{\"duration\"}}s\n          {{/if}}</td>\n          <td  data-column=\"query\" style='color:#73BF69;min-width:380px;max-width:380px;'>\n        {{reduce query}}</td>\n     {{!-- <td id=\"query_hidden\" hidden>{{query}}</td>\n     <td id=\"queryCell\" class=\"query-cell\" data-column=\"query\" style='color:#73BF69;min-width:380px;max-width:380px;'>\n        {{reduce query}}\n    </td>  --}}\n      {{#if (isNull queryid)}}\n            <td   data-column=\"queryid\" style='color:#73BF69;min-width:200px;max-width:200px;'>\n\t\t        {{queryid}}</td>\n        {{else}}\n             <td  data-column=\"queryid\" style='color:#73BF69;min-width:200px;max-width:200px;'>\n\t\t\t        <a title=\"[QueryID : {{queryid}}] Go to statements details.\"\n               style='color:#73BF69;min-width:200px; cursor: pointer; text-decoration: underline;' onclick=\"goLink('queryid', '{{queryid}}', '{{cluster_name}}', '{{dbname}}')\">{{queryid}}\n\t\t\t\t\t\t\t</a></td>\n         {{/if}}\n      <td  data-column=\"wait_event\"  style='color:#73BF69;min-width:150px;max-width:150px;'>\n        {{wait_event}}</td>\n      <td  title=\"{{title appname 15}}\"  data-column=\"appname\"  style='color:#73BF69;min-width:160px;'>\n        {{reduce2 appname}}</td>\n      <td data-column=\"client_ip\"  style='color:#73BF69;min-width:180px;max-width:180px;'>\n        {{client_ip}}</td>\n      {{!-- <td data-column=\"blocking_pids\"  style='color:#73BF69;min-width:150px;'>{{blocking_pids}}</td> --}}\n      <td data-column=\"backend_start\"  style='color:#73BF69;min-width:200px;'>{{backend_start}}</td>\n\t\t\t<td id=\"dbname{{@index}}\" hidden>{{dbname}}</td>\n\t\t\t<td id=\"clustername{{@index}}\" hidden>{{cluster_name}}</td>\n      <td id=\"time\" hidden>{{Time}}</td>\n    </tr>\n    {{/each}}\n  </tbody>\n</table>\n</div>\n</div>\n<!-- Modal -->\n<div id=\"confirmationModal\" class=\"modal\" hidden>\n <div class=\"modal-content\">\n\t <p style=\"color:white;\" id=\"modalMessage\"></p>\n\t <p id=\"username\" hidden></p>\n   <p id=\"pids\" hidden></p>\n   <p id=\"userid\" hidden></p>\n   <p id=\"status\" hidden></p>\n\t <div class=\"button-container\">\n\t <button style=\"border-color:transparent;\" onclick=\"confirmAction()\">Confirm</button>\n\t <button style=\"border-color:transparent;\" onclick=\"closeModal('confirmationModal')\">Cancel</button>\n </div>\n </div>\n</div>\n\n<!-- Modal -->\n<div id=\"promptModal\" class=\"modal\" hidden>\n <div class=\"modal-content\">\n <p style=\"color:white;\"  id=\"promptMessage\"></p>\n <input type=\"text\" id=\"promptInput\" placeholder=\"Enter your reason...\">\n <div class=\"button-container\">\n <button style=\"border-color:transparent;\" onclick=\"fn_SessionKill('{{variable \"clustername\"}}','{{variable \"dbname\"}}','{{pid}}','{{variable \"‘${__user.login}’\"}}','{{variable \"__user.id\"}}')\">Confirm</button>\n <button style=\"border-color:transparent;\" onclick=\"closeModal('promptModal')\">Cancel</button>\n </div>\n </div>\n</div>\n\n<!-- Modal -->\n<div id=\"alertModal\" class=\"modal\" hidden>\n <div class=\"modal-content\">\n <p style=\"color:white;\"  id=\"alertMessage\"></p>\n <div class=\"button-container\">\n <button style=\"border-color:transparent;\" onclick=\"closeModal('alertModal')\">Confirm</button>\n </div>\n </div>\n</div>\n\n<!-- Modal -->\n<div id=\"confirmationModal2\" class=\"modal\" hidden>\n <div class=\"modal-content\">\n <p  style=\"color:white;\" id=\"modalMessage2\"></p>\n <div class=\"button-container\">\n <button style=\"border-color:transparent;\" onclick=\"movePage()\">Confirm</button>\n <button style=\"border-color:transparent;\" onclick=\"closeModal('confirmationModal2')\">Cancel</button>\n </div>\n </div>\n</div>\n",
        "defaultContent": " <div id=\"buttons\" style=\"float:left; width:100%\">\r\n</div>\r\n<div id=\"error\">\r\n  <p id=\"errtxt\" style=\"align-items: center; color:#8D8E9A;font-size:18px;\">No data</p>\r\n</div>\r\n",
        "editor": {
          "format": "none",
          "height": 593,
          "language": "handlebars"
        },
        "editors": [
          "helpers",
          "styles",
          "afterRender"
        ],
        "externalScripts": [],
        "externalStyles": [],
        "helpers": "let bind_flag = false\r\nlet click = 0;\r\nlet originalOrder = null;\r\nlet sortOrders = {}; // Object to store sort order for each column\r\nlet sortedColumn = null;\r\nconst timefilter = replaceVariables('$timeFilter');\r\nconst timerange = replaceVariables('${__url_time_range}');\r\nlet count = false;\r\nconst from = replaceVariables('$__from');\r\nconst to = replaceVariables('$__to');\r\nconst toDate = new Date(parseInt(to));\r\nconst fromDate = new Date(parseInt(from));\r\nconst group = replaceVariables('$group');\r\nconst clustername = replaceVariables('$clustername');\r\nconst dbname = replaceVariables('$dbname');\r\n\r\n\r\n\r\nthis.timefilter = timefilter;\r\n\r\n\r\n\r\nupdateSelectAllCheckbox = () =>  {\r\n  var selectAllCheckbox = document.getElementById(\"selectAll\");\r\n  var rowCheckboxes = document.getElementsByClassName(\"rowCheckbox\");\r\n  var allChecked = true;\r\n  var allChecked2 = false;\r\n\r\n  // Check if all checkboxes in the table body are checked\r\n  for (var i = 0; i < rowCheckboxes.length; i++) {\r\n      if (!rowCheckboxes[i].checked) {\r\n          allChecked = false;\r\n      }\r\n      if (rowCheckboxes[i].checked) {\r\n          allChecked2 = true;\r\n      }\r\n  }\r\n  if(rowCheckboxes.length == 1 && rowCheckboxes[0].checked){\r\n    this.allChecked = true;\r\n  }\r\n\r\n  // Update the state of the \"Select All\" checkbox\r\n  if(!allChecked || allChecked2){\r\n    selectAllCheckbox.checked = allChecked;\r\n  }\r\n  // if (this.buttons) {\r\n  //   if(!allChecked2){\r\n  //     stopRefresh();\r\n  //   }else if (!this.refreshed){\r\n  //     stopRefresh();\r\n  //   }else{\r\n  //   }\r\n  // }\r\n}\r\n\r\nselectAllRows = () => {\r\n  const checkboxes = document.querySelectorAll('.rowCheckbox');\r\n  const selectAllCheckbox = document.getElementById('selectAll');\r\n  checkboxes.forEach(checkbox => {\r\n    checkbox.checked = selectAllCheckbox.checked;\r\n  });\r\n  // if (this.buttons) {\r\n  //   if(selectAllCheckbox.checked){\r\n  //     this.allChecked = true;\r\n  //     stopRefresh();\r\n  //   }else{\r\n  //     this.allChecked = false;\r\n  //     stopRefresh();\r\n  //   }\r\n  // }\r\n}\r\n\r\n\r\n\r\n\r\n\r\nstopRefresh = () => {\r\n  const refreshButton = document.getElementById('refresh');\r\n  \r\n  if (timefilter.includes('now')) {\r\n    this.checked = true;\r\n    this.refreshed = true;\r\n    // Get the URL from the window location\r\n    const url = window.location.href;\r\n    // Parse the URL using URLSearchParams\r\n    const params = new URLSearchParams(url);\r\n    // Get the value of the 'from' parameter\r\n    const fromValue = params.get('from');\r\n    this.originalFrom = fromValue;\r\n    this.originalTo = to;\r\n    // Push the new URL to the browser's history without reloading the page\r\n    this.from = from\r\n    this.to = to\r\n    this.timefilter = timefilter\r\n    // Initialize an empty array to store the rows\r\n    this.rows = [];\r\n\r\n    // Get all the rows in the tbody\r\n    const rows = document.querySelectorAll('#tbody_overview tr');\r\n\r\n    // Iterate over each row and push it into the this.rows array\r\n    rows.forEach(row => {\r\n        this.rows.push(row);\r\n    });\r\n     locationService.partial({ from: from, to: to });\r\n    refreshButton.innerText = 'Restart Refresh';\r\n  } else {\r\n    this.checked = false;\r\n    this.refreshed = false;\r\n    // Update the URL with the original 'from' parameter\r\n    locationService.partial({ from: this.originalFrom, to: 'now', refresh: '10s' });\r\n  }\r\n}\r\n\r\n\r\n\r\nsortTable = (column) => {\r\n  const table =  document.getElementById('table_overview');\r\n  const rows = Array.from(table.querySelectorAll('#tbody_overview tr'));\r\n\r\n  if (click == 0) {\r\n    originalOrder = [...rows];\r\n    click += 1;\r\n  }\r\n  if (sortedColumn === column) {\r\n    sortOrders[column] *= -1;\r\n    if (sortOrders[column] === 1) {\r\n      if(rows){\r\n        rows.length = 0;\r\n        rows.push(...originalOrder);\r\n        sortedColumn = null;\r\n      }else{\r\n        rows.length = 0;\r\n        rows.push(...originalOrder);\r\n        sortedColumn = null;\r\n      }\r\n    }\r\n  } else {\r\n    sortOrders[column] = 1;\r\n    sortedColumn = column;\r\n  }\r\n\r\n  const allColumnHeaders = table.querySelectorAll('th');\r\n  allColumnHeaders.forEach(header => {\r\n    header.classList.remove('sorted');\r\n    removeSortIcon(header);\r\n  });\r\n\r\n  if (sortedColumn) {\r\n    const currentSortedColumn = table.querySelector(`th[id=\"${column}\"]`);\r\n    if (currentSortedColumn) {\r\n      currentSortedColumn.classList.add('sorted');\r\n      addSortIcon(currentSortedColumn, sortOrders[column]);\r\n    }\r\n  }\r\n\r\n  rows.sort((a, b) => {\r\n    const aValueElement = a.querySelector(`td[data-column=\"${column}\"]`);\r\n    const bValueElement = b.querySelector(`td[data-column=\"${column}\"]`);\r\n\r\n    const aValue = aValueElement ? aValueElement.textContent.trim() : '';\r\n    const bValue = bValueElement ? bValueElement.textContent.trim() : '';\r\n\r\n    if (column === 'duration') {\r\n      const aDuration = parseDuration(aValue);\r\n      const bDuration = parseDuration(bValue);\r\n\r\n      return sortOrders[column] * (aDuration - bDuration);\r\n    } \r\n    else if (column === 'blocking_pids') {\r\n        // Custom sorting for 'blocking_pids' column\r\n        if (aValue === '' && bValue === '') {\r\n            return 0;\r\n        } else if (aValue === '') {\r\n            return -1;\r\n        } else if (bValue === '') {\r\n            return 1;\r\n        } else {\r\n            // If both values are not blank, use the sortOrder\r\n            return sortOrders[column] * (parseFloat(aValue) - parseFloat(bValue));\r\n        }\r\n    } \r\n    else if (isNaN(aValue) || isNaN(bValue)) {\r\n      return sortOrders[column] * aValue.localeCompare(bValue, 'en', { sensitivity: 'base' });\r\n    } else {\r\n      return sortOrders[column] * (parseFloat(aValue) - parseFloat(bValue));\r\n    }\r\n  });\r\n\r\n  if(!sortedColumn){\r\n    rows.length = 0;\r\n    rows.push(...originalOrder);\r\n  }\r\n  const tbody = table.querySelector('tbody');\r\n  tbody.innerHTML = '';\r\n  rows.forEach(row => tbody.appendChild(row));\r\n};\r\n\r\n// Function to add the sort icon to the header\r\nfunction addSortIcon(header, sortOrder) {\r\n  const icon = document.createElement('i');\r\n  icon.classList.add('material-icons'); // You can adjust the icon class based on your icon library\r\n  icon.textContent = sortOrder === 1 ? '▲' : '▼';\r\n  icon.style.textAlign = 'right';\r\n  header.appendChild(icon);\r\n}\r\n\r\n// Function to remove the sort icon from the header\r\nfunction removeSortIcon(header) {\r\n  const icon = header.querySelector('.material-icons');\r\n  if (icon) {\r\n    header.removeChild(icon);\r\n  }\r\n}\r\n// Function to parse duration string and convert it to seconds\r\nfunction parseDuration(durationString) {\r\n  const durationParts = durationString.split(' ');\r\n  let totalSeconds = 0;\r\n\r\n  for (const part of durationParts) {\r\n    const match = part.match(/(\\d*\\.?\\d+)([a-z]+)/i); // Updated regex to allow floating-point numbers\r\n    if (match) {\r\n      const value = parseFloat(match[1]); // Parse float instead of int\r\n      const unit = match[2].toLowerCase();\r\n\r\n      // Convert different time units to seconds\r\n      switch (unit) {\r\n        case 's':\r\n          totalSeconds += value;\r\n          break;\r\n        case 'm':\r\n          totalSeconds += value * 60;\r\n          break;\r\n        case 'h':\r\n          totalSeconds += value * 60 * 60;\r\n          break;\r\n        // Add more cases if needed (e.g., 'd' for days)\r\n      }\r\n    }\r\n  }\r\n\r\n  return totalSeconds;\r\n}\r\n\r\n// Function to parse duration string and convert it to seconds\r\nfunction parseBlocking(blockingString) {\r\n  const value = parseInt(blockingString);\r\n  return value;\r\n}\r\n\r\nkillall = async (username, userid,status) => {\r\n      let reason = \"kill all\"\r\n      if(status == \"cancel\"){\r\n\t\t\t\t\treason = \"cancel all\";\r\n\t\t\t}\r\n\t    const checkboxes = document.querySelectorAll('.rowCheckbox');\r\n\t    const selectedRows = [];\r\n\t\t\tconst currentURL = window.location.href;\r\n\t\t  // Create a URL object\r\n\t\t  const urlObject = new URL(currentURL);\r\n\t\t  const redirectURL = `${urlObject.protocol}//${urlObject.host}`;\r\n\t\t  url_workbench = redirectURL;\r\n\t\t  // Change the port to 9030\r\n\t\t  urlObject.port = '9030';\r\n\t\t  // Extract the base URL\r\n\t\t  const baseURL = `${urlObject.protocol}//${urlObject.host}`;\r\n\t\t  var url = baseURL + \"/processKill\";\r\n      if(status == \"cancel\"){\r\n\t\t\t\turl = baseURL + \"/processStop\";\r\n\t\t\t}\r\n\t    checkboxes.forEach((checkbox, i) => {\r\n\t        if (checkbox.checked) {\r\n\t            selectedRows.push(i);\r\n\t        }\r\n\t    });\r\n    for (const [index, selectedIndex] of selectedRows.entries()) {\r\n        await new Promise((resolve) => {\r\n            setTimeout(() => {\r\n                let pid = document.getElementById(\"pid\" + selectedIndex).innerText;\r\n                let dbname = document.getElementById(\"dbname\" + index).innerText;\r\n                let clustername = document.getElementById(\"clustername\" + index).innerText;\r\n                const data = {\r\n                    hostname: clustername,\r\n                    dbname: dbname,\r\n                    pid: pid,\r\n                    user: username,\r\n                    userid: userid,\r\n                    reason: reason,\r\n                    url: \"\"\r\n                };\r\n                fn_SessionKill_multi(data, url).then((result) => {\r\n                  if (result === 1) {\r\n                      if (index === selectedRows.length - 1) {\r\n                          if(status == \"cancel\"){\r\n                              showAlertModal(\"Cancel query success\");\r\n                          } else {\r\n                              showAlertModal(\"Process Kill success\");\r\n                          }\r\n                      }\r\n                      resolve();\r\n                  } else {\r\n                      if(status == \"cancel\"){\r\n                          showAlertModal(\"Fail to Cancel Query\");\r\n                      } else {\r\n                          showAlertModal(\"Fail to Kill process\");\r\n                      }\r\n                  }\r\n              })\r\n            }, 1);\r\n        });\r\n    }\r\n};\r\n\r\nfn_SessionKill_multi = (data,url) => {\r\n\treturn new Promise((resolve) => {\r\n        setTimeout(() => {\r\n            fetch(url, {\r\n\t\t\t\t\t\t\t    method: 'post',\r\n\t\t\t\t\t\t\t    body: JSON.stringify(data)\r\n\t\t\t\t\t\t\t  })\r\n\t\t\t\t\t\t\t    .then(res => res.json())\r\n\t\t\t\t\t\t\t    .then(res => {\r\n\t\t\t\t\t\t\t      if (res.success) {\r\n\t\t\t\t\t\t\t        resolve(1);\r\n\t\t\t\t\t\t\t      } else if (res == 1) {\r\n\t\t\t\t\t\t\t\t\t\t\tresolve(1);\r\n\t\t\t\t\t\t\t      } else if (res == 0) {\r\n\t\t\t\t\t\t\t        resolve(0);\r\n\t\t\t\t\t\t\t      } else if (res == -1) {\r\n\t\t\t\t\t\t\t        resolve(0);\r\n\t\t\t\t\t\t\t      } else if (res == -2) {\r\n\t\t\t\t\t\t\t\t      resolve(0);\r\n\t\t\t\t\t\t\t      } else {\r\n\t\t\t\t\t\t\t\t      resolve(0);\r\n\t\t\t\t\t\t\t      }\r\n\t\t\t\t\t\t\t    })\r\n                  .catch((error) => {\r\n                    // Check if the error is due to CORS\r\n                    if (error.name === 'TypeError' && error.message === 'Failed to fetch') {\r\n                        //console.error('CORS Error occurred:', error);\r\n                        resolve(1);\r\n                    } else {\r\n                        // Handle other errors\r\n                        console.error('Error occurred:', error);\r\n                        resolve(0);\r\n                    }\r\n                    \r\n            });\r\n        }, 50);\r\n    });\r\n} \r\n\r\n\r\n\r\ngetUser = (clustername, dbname, pid, userLogin, userId, action, port) => {\r\n  const currentURL = window.location.href;\r\n  const urlObject = new URL(currentURL);\r\n  const redirectURL = `${urlObject.protocol}//${urlObject.host}`;\r\n  const url = redirectURL + '/api/user/orgs';\r\n  action_temp = action;\r\n  fetch(url, {\r\n    method: 'get',\r\n  })\r\n    .then(res => res.json())\r\n    .then(res => {\r\n      if (res[0].role == 'Viewer') {\r\n        var question = '';\r\n        if (action == 'kill') {\r\n          question = \"Viewers do not have the privilege to kill this session.\"\r\n        } else {\r\n          question = \"Viewers do not have the privilege to stop this query.\"\r\n        }\r\n        showAlertModal(question);\r\n      } else {\r\n        openConfirmationModal(clustername, dbname, pid, userLogin, userId, action, port);\r\n      }\r\n    })\r\n    .catch(error => {\r\n      console.error('Error fetching user data:', error);\r\n    });\r\n}\r\n\r\ngoLink= (category, params,clustername,dbname) => {\r\n\tvar link = '';\r\n\t// Get the current URL\r\n  const currentURL = window.location.href;\r\n  // Create a URL object\r\n  const urlObject = new URL(currentURL);\r\n  const redirectURL = `${urlObject.protocol}//${urlObject.host}`;\r\n\tif(category == 'pid'){\r\n     link = '/d/experdb-session-history?orgId=1&var-clustername=' +\r\n     clustername + '&var-dbname=' + dbname + '&var-group=' + group +\r\n     '&var-pid=' +\r\n      params\r\n      + '&' + timerange\r\n\t}else{\r\n\t   link = '/d/experdb-query-details/query-details?orgId=1&var-clustername=' +\r\n     clustername + '&var-dbname=' + dbname + \r\n     '&var-queryid=' +\r\n      params\r\n\t}\r\n  window.location.href = redirectURL + link\r\n}\r\n\r\n\r\n\r\n\r\nopenConfirmationModal = (username, userid,status) => {\r\n  const role = this.grafanaBootData.user.orgRole;\r\n  var action = status\r\n  if(role == 'Viewer'){\r\n      var question = '';\r\n      this.message = \"Pid does not exist\"\r\n        if (action == 'kill') {\r\n          question = \"Viewers do not have the privilege to kill this session.\"\r\n        } else {\r\n          question = \"Viewers do not have the privilege to stop this query.\"\r\n        }\r\n        showAlertModal(question);\r\n  }else{\r\n      const checkboxes = document.querySelectorAll('.rowCheckbox');\r\n      const selectedRows = [];\r\n      var pids = [];\r\n      checkboxes.forEach((checkbox, i) => {\r\n          if (checkbox.checked) {\r\n              selectedRows.push(i);\r\n          }\r\n      });\r\n      for (const [index, selectedIndex] of selectedRows.entries()) {\r\n            let pid = document.getElementById(\"pid\" + selectedIndex).innerText;\r\n            pids.push(pid)\r\n        }\r\n\r\n      if (pids.length) {\r\n        var question = '';\r\n        var pid_new = pids;\r\n        if (pids.length > 8) {\r\n          pids = pids.slice(0, 8);\r\n          pid_new = pids.join(', ');\r\n          pid_new += \"...\";\r\n        }\r\n        if (action == 'kill') {\r\n          question = \"Are you sure you want to kill this session?\"\r\n        } else {\r\n          question = \"Are you sure you want to cancel this query?\"\r\n        }\r\n        question += \"\\n pid: \" + pid_new \r\n        this.message = question\r\n\r\n        const dynamicMessage = question;\r\n        document.getElementById('modalMessage').innerText = dynamicMessage;\r\n        document.getElementById('username').innerText = username;\r\n        document.getElementById('userid').innerText = userid;\r\n        document.getElementById('status').innerText = status;\r\n        document.getElementById('pids').innerText = pids;\r\n\r\n        // Show the modal\r\n        const modal = document.getElementById('confirmationModal');\r\n        modal.removeAttribute('hidden');\r\n      } else {\r\n        this.message = \"Pid does not exist\"\r\n        showAlertModal(\"Pid does not exist\");\r\n      }\r\n  }\r\n}\r\n\r\nconfirmAction = () => {\r\n  var username =  document.getElementById('username').innerText;\r\n  var userid=  document.getElementById('userid').innerText ;\r\n  var status = \tdocument.getElementById('status').innerText ;\r\n  // After performing the action, close the modal\r\n  closeModal('confirmationModal');\r\n  killall(username, userid,status);\r\n}\r\n\r\nopenPromptModal = (clustername, dbname, pid, userLogin, userId, action, message) => {\r\n  // Set dynamic message based on parameters\r\n  const dynamicMessage = message;\r\n  document.getElementById('promptMessage').innerText = dynamicMessage;\r\n  // Show the modal\r\n  const modal = document.getElementById('promptModal');\r\n  modal.removeAttribute('hidden');\r\n}\r\n\r\nfn_SessionKill = (hostname, dbname, pid, username, userid) => {\r\n\thostname = document.getElementById('cluster_name').innerText\r\n\tdbname = document.getElementById('dbname').innerText \r\n  pid = document.getElementById('pid').innerText;\r\n  var userInput = $('#promptInput').val();\r\n  closeModal('promptModal');\r\n  var dbname_temp = dbname;\r\n  var pid = pid;\r\n  // Get the current URL\r\n  const currentURL = window.location.href;\r\n  // Create a URL object\r\n  const urlObject = new URL(currentURL);\r\n  const redirectURL = `${urlObject.protocol}//${urlObject.host}`;\r\n  url_workbench = redirectURL;\r\n  // Change the port to 9030\r\n  urlObject.port = '9030';\r\n  // Extract the base URL\r\n  const baseURL = `${urlObject.protocol}//${urlObject.host}`;\r\n  var status =  document.getElementById('action').innerText;\r\n \r\n\r\n  var url = baseURL + \"/processKill\";\r\n  //var url = \"http://localhost:9030/processKill\";\r\n  if (status == 'stop') {\r\n    url = baseURL + \"/processStop\";\r\n    //userInput = $('#promptInput').val();\r\n    //url = \"http://localhost:9030/processStop\";\r\n  } \r\n\r\n  const data = {\r\n    hostname: hostname,\r\n    dbname: dbname,\r\n    pid: pid,\r\n    url: redirectURL,\r\n    user: username,\r\n    userid: userid,\r\n    reason: userInput\r\n  };\r\n  // User clicked \"OK\" or confirmed\r\n  fetch(url, {\r\n    method: 'post',\r\n    body: JSON.stringify(data)\r\n  })\r\n    .then(res => res.json())\r\n    .then(res => {\r\n      var process = 'Process ';\r\n      var process2 = ' process';\r\n      if (status == 'stop') {\r\n        process = 'Query '\r\n        process2 = ' query'\r\n        status = 'cancel'\r\n      }\r\n      if (res.success) {\r\n        showAlertModal(process + status + \" success\");\r\n      } else if (res == 1) {\r\n        showAlertModal(process + status + \" success\");\r\n        hostname_workbench = hostname;\r\n        dbname_workbench = dbname;\r\n        showPageModal(\"Do you want to move to session workload page?\");\r\n      } else if (res == 0) {\r\n        showAlertModal(\"Failed to \" + status + process2);\r\n      } else if (res == -1) {\r\n        showAlertModal(\"Failed to connect to the database\");\r\n      } else if (res == -2) {\r\n        //showAlertModal (\"Viewer cannot \" + status + process2);\r\n      } else {\r\n        showAlertModal(\"Failed to \" + status + process2);\r\n      }\r\n    })\r\n\r\n}\r\nmovePage = () => {\r\n  // User clicked \"OK\"\r\n  window.location.href = url_workbench + '/d/experdb-session-workload/session-workload?orgId=1&var-clustername='\r\n    + hostname_workbench\r\n    + '&var-dbname='\r\n    + dbname_workbench\r\n    + '&var-agg_interval=10s&var-top_queries=10';\r\n  // Add your logic for the \"OK\" case here\r\n}\r\n\r\nshowAlertModal = (question) => {\r\n  const dynamicMessage = question;\r\n  document.getElementById('alertMessage').innerText = dynamicMessage;\r\n\r\n  // Show the modal\r\n  const modal = document.getElementById('alertModal');\r\n  modal.removeAttribute('hidden');\r\n}\r\n\r\nshowPageModal = (question) => {\r\n  const dynamicMessage = question;\r\n  document.getElementById('modalMessage2').innerText = dynamicMessage;\r\n\r\n  // Show the modal\r\n  const modal = document.getElementById('confirmationModal2');\r\n  modal.removeAttribute('hidden');\r\n}\r\n\r\ncloseModal = (id) => {\r\n  // Hide the modal\r\n  const modal = document.getElementById(id);\r\n  modal.setAttribute('hidden', true);\r\n  if(id == 'alertModal'){\r\n    if(this.message == \"Pid does not exist\"){\r\n    }else{\r\n      const selectAllCheckbox = document.getElementById('selectAll');\r\n      selectAllCheckbox.checked = false;\r\n      this.allChecked = false;\r\n      // Get the current URL\r\n      const currentURL = window.location.href;\r\n      // Create a URL object\r\n      const urlObject = new URL(currentURL);\r\n      const redirectURL = `${urlObject.protocol}//${urlObject.host}`;\r\n      link = '/d/experdb-session-workload/2-1-session-workload?orgId=1&var-group=${group}&var-clustername=' +\r\n      clustername + '&var-dbname=' + dbname + '&from=30m&to=now' \r\n      //window.location.href = redirectURL + link\r\n      locationService.partial({ from: this.originalFrom, to: 'now', refresh: '10s' });\r\n    } \r\n\t}\r\n}\r\n\r\n// Register a custom Handlebars helper\r\n\r\nhandlebars.registerHelper('title', function (value, length) {\r\n  if(value){\r\n    if(value.length > length){\r\n      return value;\r\n    }else{\r\n      return null;\r\n    }\r\n  }else{\r\n    return null;\r\n  }\r\n});\r\n\r\nhandlebars.registerHelper('isRefresh', function (value) {\r\n  if(timefilter.indexOf('now()') == -1 ){\r\n    return true;\r\n  }else{\r\n    return false;\r\n  }\r\n});\r\n\r\nhandlebars.registerHelper('isCurrent', function (value) {\r\n  const current = new Date(); // Use new Date() to get the current date and time\r\n  const timeDifferenceInSeconds = Math.abs(Math.floor((current - toDate) / 1000));\r\n\r\n  // Check if the difference is less than 10 seconds\r\n  if (timeDifferenceInSeconds < 10) {    \r\n    return false;\r\n  } else {\r\n    return true;\r\n  }\r\n});\r\n\r\nhandlebars.registerHelper('reduce3', function (value) {\r\n   if(value){\r\n\t\t\tif(value.length > 8){\r\n\t\t\t\treturn value.substr(0,8) + \"...\";\r\n      }else{\r\n\t\t\t\treturn value;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n});\r\n\r\n\r\nhandlebars.registerHelper('reduce2', function (value) {\r\n   if(value){\r\n\t\t\tif(value.length > 15){\r\n\t\t\t\treturn value.substr(0,15) + \"...\";\r\n      }else{\r\n\t\t\t\treturn value;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n});\r\n\r\n\r\nhandlebars.registerHelper('reduce', function (value) {\r\n   if(value){\r\n    value = value.trim();\r\n\t\t\tif(value.length >47){\r\n\t\t\t\treturn value.substr(0,47) + \"...\";\r\n      }else{\r\n\t\t\t\treturn value;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n});\r\n\r\nhandlebars.registerHelper('isNull', function (value) {\r\n  return value === null;\r\n});\r\n\r\nhandlebars.registerHelper('replace', function (context, pattern, replacement) {\r\n  var context_temp = \"\";\r\n  if (context) {\r\n    context_temp = context.replaceAll(pattern, replacement);\r\n  }\r\n  return context_temp;\r\n});\r\n\r\nhandlebars.registerHelper('merge', (str, sep, query) => {\r\n  let tempStr = \"\";\r\n\r\n  let tempQuery = \"\";\r\n  if (str) {\r\n    tempStr = str.split(sep)\r\n    tempStr.map((v, i) => tempQuery = tempQuery.replace(\"$\" + (i + 1), v))\r\n    tempQuery = query[0];\r\n  } else {\r\n\r\n  }\r\n\r\n  return tempQuery\r\n});\r\n\r\nhandlebars.registerHelper('time_formatter', (time) => {\r\n  let tempTime = new Date(time)\r\n  let month = tempTime.getMonth() + 1;\r\n  let day = tempTime.getDate();\r\n  let hour = tempTime.getHours();\r\n  let minute = tempTime.getMinutes();\r\n  let second = tempTime.getSeconds();\r\n\r\n  month = month >= 10 ? month : '0' + month;\r\n  day = day >= 10 ? day : '0' + day;\r\n  hour = hour >= 10 ? hour : '0' + hour;\r\n  minute = minute >= 10 ? minute : '0' + minute;\r\n  second = second >= 10 ? second : '0' + second;\r\n\r\n  let formatted_date = tempTime.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;\r\n  return formatted_date;\r\n});\r\n",
        "renderMode": "allRows",
        "styles": "\r\n/* Adjustments for Dark Mode */\r\n@media (prefers-color-scheme: dark) {\r\n  :root {\r\n    --background-color: var(--background-dark);\r\n    --text-color: var(--text-dark);\r\n  }\r\n\r\n  /* Additional styling for dark mode */\r\n  thead, tbody tr {\r\n    background-color: var(--background-dark);\r\n  }\r\n}\r\n\r\n/* Adjustments for Light Mode */\r\n@media (prefers-color-scheme: light) {\r\n  :root {\r\n    --background-color: var(--background-light);\r\n    --text-color: var(--text-light);\r\n  }\r\n\r\n  /* Additional styling for light mode */\r\n  thead, tbody tr {\r\n    background-color: var(--background-light);\r\n  }\r\n\r\n  .cancel-button {\r\n      color: rgb(6, 6, 6);  \r\n  }\r\n}\r\n\r\n\r\n.panel-loading{\r\n  display:none !important;\r\n}\r\n\r\nthead {\r\n  max-height: 35px !important;\r\n  display: flex;\r\n  //background: black;\r\n}\r\n\r\n\r\nth {\r\n  text-align: left;\r\n  background-color: #f2f2f2;\r\n  height: 35px;\r\n  line-height: 30px;\r\n}\r\n\r\n\r\nthead tr {\r\n  display: flex;\r\n  width: 100%;\r\n  table-layout: fixed;\r\n  max-height: 54px !important;\r\n}\r\n\r\ntbody tr {\r\n  display: flex;\r\n  width: 100%;\r\n  table-layout: fixed;\r\n  max-height: 30px !important;\r\n  //background-color: #111214;\r\n  \r\n}\r\ntbody {\r\n\t//border-color: rgb(30, 33, 37);\r\n}\r\n\r\n\r\ntable {\r\n  border-collapse: collapse;\r\n  width: 100%;\r\n  height: 70px !important;\r\n  //border-color: rgb(30, 33, 37);\r\n}\r\n\r\ntable th {\r\n  //display: flex;\r\n  background: transparent;\r\n  width: 100%;\r\n  table-layout: fixed;\r\n  max-height: 54px !important;\r\n}\r\ntable td {\r\n  //display: flex;\r\n  width: 100%;\r\n  table-layout: fixed;\r\n  max-height: 30px !important;\r\n}\r\n\r\n\r\ntd {\r\n  //font-size: 9pt;\r\n  font-size: 1rem;\r\n  //border-color: rgb(30, 33, 37) !important;\r\n}\r\n\r\n.custom-button {\r\n    -webkit-text-size-adjust: 100%;\r\n    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n    font-kerning: normal;\r\n    color-scheme: dark;\r\n    --sash-size: 4px;\r\n    font-weight: 400;\r\n    letter-spacing: 0.01071em;\r\n    font-family: Inter, Helvetica, Arial, sans-serif;\r\n    box-sizing: inherit;\r\n    touch-action: manipulation;\r\n    display: inline-block;\r\n    position: relative;\r\n    font-size: 14px;\r\n    height: 32px;\r\n    line-height: 26px;\r\n    padding: 0px 16px;\r\n    border-radius: 2px;\r\n    background: rgba(0, 0, 0, 0.5); /* 다크 테마에 맞는 배경색 */\r\n    cursor: pointer;\r\n    z-index: 1;\r\n    flex: 0 0 auto;\r\n    text-align: center;\r\n    user-select: none;\r\n    white-space: nowrap;\r\n    color: rgb(204, 204, 220);\r\n    border: none; /* 테두리 제거 */\r\n    margin-bottom: 5px;\r\n}\r\n\r\n\r\n.kill-button {\r\n    -webkit-text-size-adjust: 100%;\r\n    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n    color-scheme: dark;\r\n    --sash-size: 4px;\r\n    box-sizing: inherit;\r\n    font: inherit;\r\n    overflow: visible;\r\n    text-transform: none;\r\n    -webkit-appearance: button;\r\n    touch-action: manipulation;\r\n    margin: 0;\r\n    letter-spacing: 0.01071em;\r\n    display: inline-flex;\r\n    -webkit-box-align: center;\r\n    align-items: center;\r\n    font-size: 14px;\r\n    font-weight: 500;\r\n    font-family: Inter, Helvetica, Arial, sans-serif;\r\n    padding: 0px 16px;\r\n    height: 32px;\r\n    line-height: 30px;\r\n    vertical-align: middle;\r\n    cursor: pointer;\r\n    border-radius: 2px;\r\n    background: rgb(209, 14, 92);\r\n    color: rgb(204, 204, 220);\r\n    border: 1px solid transparent;\r\n    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\r\n    margin-right: 5px;\r\n    margin-bottom: 5px;\r\n}\r\n\r\n.cancel-button {\r\n    -webkit-text-size-adjust: 100%;\r\n    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n    color-scheme: dark;\r\n    --sash-size: 4px;\r\n    visibility: visible;\r\n    box-sizing: inherit;\r\n    font: inherit;\r\n    overflow: visible;\r\n    text-transform: none;\r\n    -webkit-appearance: button;\r\n    touch-action: manipulation;\r\n    margin: 0;\r\n    letter-spacing: 0.01071em;\r\n    display: inline-flex;\r\n    -webkit-box-align: center;\r\n    align-items: center;\r\n     font-size: 14px;\r\n    font-weight: 500;\r\n    font-family: Inter, Helvetica, Arial, sans-serif;\r\n    padding: 0px 16px;\r\n    height: 32px;\r\n    line-height: 22px;\r\n    vertical-align: middle;\r\n    cursor: pointer;\r\n    border-radius: 2px;\r\n    background: rgba(204, 204, 220, 0.16);\r\n    border: 1px solid transparent;\r\n    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\r\n    margin-right: 5px;\r\n    margin-bottom: 5px;\r\n    color: rgb(204, 204, 220);\r\n}\r\n\r\n\r\ncustom-button2 {\r\n    -webkit-text-size-adjust: 100%;\r\n    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n    color-scheme: dark;\r\n    --sash-size: 4px;\r\n    pointer-events: auto;\r\n    box-sizing: inherit;\r\n    font: inherit;\r\n    overflow: visible;\r\n    text-transform: none;\r\n    -webkit-appearance: button;\r\n    touch-action: manipulation;\r\n    margin: 0;\r\n    letter-spacing: 0.01071em;\r\n    display: inline-flex;\r\n    -webkit-box-align: center;\r\n    align-items: center;\r\n    font-size: 14px;\r\n    font-weight: 500;\r\n    font-family: Inter, Helvetica, Arial, sans-serif;\r\n    padding: 0px 15px;\r\n    height: 32px;\r\n    line-height: 30px;\r\n    vertical-align: middle;\r\n    cursor: pointer;\r\n    border-radius: 2px;\r\n    background: transparent;\r\n    color: rgb(204, 204, 220);\r\n    border: 1px solid rgba(204, 204, 220, 0.25);\r\n    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\r\n    margin-bottom: 5px;\r\n}\r\n\r\n\r\n\r\n.custom-button2 {\r\n  margin-top: 9px;\r\n  display: inline-flex;\r\n  font-size:11px;\r\n  //font-weight: 500;\r\n  font-family: Inter, Helvetica, Arial, sans-serif;\r\n  //padding: 0px 15px;\r\n  height: 32px;\r\n  line-height: 30px;\r\n  cursor: pointer;\r\n  border-radius: 2px;\r\n  background: rgba(204, 204, 220, 0.16);\r\n  color: rgb(204, 204, 220);\r\n  border: 1px solid transparent;\r\n  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\r\n}\r\n.button-container {\r\n  display: flex; /* Use flexbox to make the buttons appear in the same row */\r\n  gap: 10px;     /* Optional: Add some space between the buttons */\r\n}\r\n\r\n\r\n\r\n#confirmationModal,\r\n#confirmationModal2,\r\n#confirmationModal3,\r\n#confirmationModal4,\r\n#promptModal,\r\n#promptModal_s {\r\n  background-color: black;\r\n  display: flex;\r\n  flex-direction: column;\r\n  align-items: center;\r\n  position: fixed;\r\n  top: 40%;\r\n  //left: 50%;\r\n  transform: translate(50%, -50%) translateX(-50%);\r\n}\r\n\r\n#alertModal {\r\n  background-color: black;\r\n  display: flex;\r\n  flex-direction: column;\r\n  align-items: center;\r\n  position: fixed;\r\n  top: 40%;\r\n  //left: 50%;\r\n  transform: translate(50%, -50%) translateX(-50%);\r\n}\r\n\r\n\r\n#error {\r\n    display: flex;\r\n    align-items: center;\r\n    justify-content: center;\r\n    height: 16vh;\r\n    margin: 0;\r\n    overflow: hidden; /* Set overflow to hidden */\r\n}\r\n\r\n#errtxt {\r\n    text-align: center;\r\n    overflow: hidden; /* Set overflow to hidden */\r\n    margin: 0; /* Remove default margin */\r\n}",
        "wrap": true
      },
      "pluginVersion": "4.5.0",
      "targets": [
        {
          "datasource": "0",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "orderByTime": "ASC",
          "policy": "default",
          "query": " SELECT\n last(\"user\") AS \"user\",\nlast(\"backend_start_text\") as \"backend_start\",\n last(\"appname\") AS \"appname\",\n last(\"client_ip\") AS \"client_ip\",\n last(\"duration_s\") AS \"duration\",\n last(\"query_text\") AS \"query\",\n last(\"state\") AS \"state\",\nlast(\"bind_variables\") AS \"bind_variables\"\n FROM\n stat_activity_realtime\n WHERE\n $timeFilter\n    AND duration_s >= 1\n -- AND \"duration_s\" <=  $max\n AND \"cluster_name\" =~ /^$clustername$/ \n GROUP BY pid, wait_event,queryid, dbname,cluster_name, query_start\n-- LIMIT 100",
          "rawQuery": true,
          "refId": "B",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "timeFrom": "11s",
      "title": "Active sessions realtime",
      "transformations": [],
      "type": "marcusolsson-dynamictext-panel"
    }
  ],
  "refresh": "10s",
  "revision": 1,
  "schemaVersion": 38,
  "style": "dark",
  "tags": [
    "experdb"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false
        },
        "datasource": {
          "type": "postgres",
          "uid": "1"
        },
        "definition": "SELECT 'All' AS __text, 0 AS __value where $role_id in (2, 3) \nUNION ALL\nselect g_name AS __text, g_id AS __value from cluster_group cg where $role_id in (2, 3) or exists (select 1 from cluster_group_user cgu where cgu.g_id = cg.g_id and cgu.u_id =   ${__user.id}) ",
        "hide": 0,
        "includeAll": false,
        "label": "group",
        "multi": false,
        "name": "group",
        "options": [],
        "query": "SELECT 'All' AS __text, 0 AS __value where $role_id in (2, 3) \nUNION ALL\nselect g_name AS __text, g_id AS __value from cluster_group cg where $role_id in (2, 3) or exists (select 1 from cluster_group_user cgu where cgu.g_id = cg.g_id and cgu.u_id =   ${__user.id}) ",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false
        },
        "datasource": {
          "type": "postgres",
          "uid": "1"
        },
        "definition": "select ms.ms_unique_name \n     from monitored_server ms \n     join monitored_db md on ms.ms_unique_name  = md.md_unique_name  \n     left join cluster_group_server cgs on ms.ms_unique_name  = cgs.ms_unique_name  \n    where md_is_enabled = true and ($group = 0 or cgs.g_id=$group);",
        "hide": 0,
        "includeAll": true,
        "multi": true,
        "name": "clustername",
        "options": [],
        "query": "select ms.ms_unique_name \n     from monitored_server ms \n     join monitored_db md on ms.ms_unique_name  = md.md_unique_name  \n     left join cluster_group_server cgs on ms.ms_unique_name  = cgs.ms_unique_name  \n    where md_is_enabled = true and ($group = 0 or cgs.g_id=$group);",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      },
      {
        "current": {
          "selected": false
        },
        "datasource": {
          "type": "influxdb",
          "uid": "0"
        },
        "definition": "SHOW TAG VALUES FROM \"db_health\" WITH KEY = \"dbname\"",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "dbname",
        "options": [],
        "query": "SHOW TAG VALUES FROM \"db_health\" WITH KEY = \"dbname\"",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      },
      {
        "auto": true,
        "auto_count": 30,
        "auto_min": "5s",
        "current": {
          "selected": false,
          "text": "auto",
          "value": "$__auto_interval_agg_interval"
        },
        "hide": 2,
        "name": "agg_interval",
        "options": [
          {
            "selected": true,
            "text": "auto",
            "value": "$__auto_interval_agg_interval"
          },
          {
            "selected": false,
            "text": "5s",
            "value": "5s"
          },
          {
            "selected": false,
            "text": "10s",
            "value": "10s"
          },
          {
            "selected": false,
            "text": "30s",
            "value": "30s"
          },
          {
            "selected": false,
            "text": "1m",
            "value": "1m"
          },
          {
            "selected": false,
            "text": "5m",
            "value": "5m"
          },
          {
            "selected": false,
            "text": "15m",
            "value": "15m"
          },
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "3h",
            "value": "3h"
          },
          {
            "selected": false,
            "text": "6h",
            "value": "6h"
          },
          {
            "selected": false,
            "text": "12h",
            "value": "12h"
          },
          {
            "selected": false,
            "text": "1d",
            "value": "1d"
          },
          {
            "selected": false,
            "text": "7d",
            "value": "7d"
          },
          {
            "selected": false,
            "text": "30d",
            "value": "30d"
          }
        ],
        "query": "5s,10s,30s,1m,5m,15m,1h,3h,6h,12h,1d,7d,30d",
        "queryValue": "",
        "refresh": 2,
        "skipUrlSync": false,
        "type": "interval"
      },
      {
        "current": {
          "selected": false,
          "text": "3",
          "value": "3"
        },
        "datasource": {
          "type": "influxdb",
          "uid": "0"
        },
        "definition": "select count(last) from (SELECT last(deadlocks) FROM  kpi where $timeFilter and cluster_name =~ /^$clustername$/ group by cluster_name)",
        "hide": 2,
        "includeAll": false,
        "multi": false,
        "name": "registers",
        "options": [],
        "query": "select count(last) from (SELECT last(deadlocks) FROM  kpi where $timeFilter and cluster_name =~ /^$clustername$/ group by cluster_name)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false
        },
        "datasource": {
          "type": "influxdb",
          "uid": "0"
        },
        "definition": "SELECT cluster_name as sessiontop, top(active, $Top) from \n(\n   SELECT last(\"active\") as active FROM backends where $timeFilter  GROUP BY cluster_name fill(none)\n)  \nwhere cluster_name =~ /^$clustername$/",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "sessiontop",
        "options": [],
        "query": "SELECT cluster_name as sessiontop, top(active, $Top) from \n(\n   SELECT last(\"active\") as active FROM backends where $timeFilter  GROUP BY cluster_name fill(none)\n)  \nwhere cluster_name =~ /^$clustername$/",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false
        },
        "datasource": {
          "type": "influxdb",
          "uid": "0"
        },
        "definition": "SELECT cluster_name as logicaliotop, top(logicalio, $Top)  from \n(\n   SELECT (max(tup_inserted) - min(tup_inserted) + max(tup_updated) - min(tup_updated)  +  max(tup_deleted) - min(tup_deleted)) as logicalio\n   from db_stats  WHERE  $timeFilter\n   GROUP BY  cluster_name  fill(0)\n) \n   WHERE logicalio >= 0 \n   AND cluster_name  =~ /^$clustername$/",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "logicaliotop",
        "options": [],
        "query": "SELECT cluster_name as logicaliotop, top(logicalio, $Top)  from \n(\n   SELECT (max(tup_inserted) - min(tup_inserted) + max(tup_updated) - min(tup_updated)  +  max(tup_deleted) - min(tup_deleted)) as logicalio\n   from db_stats  WHERE  $timeFilter\n   GROUP BY  cluster_name  fill(0)\n) \n   WHERE logicalio >= 0 \n   AND cluster_name  =~ /^$clustername$/",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": "3",
          "value": "3"
        },
        "datasource": {
          "type": "postgres",
          "uid": "2"
        },
        "definition": "select role_id from user_role where user_id = ${__user.id} and org_id = 1",
        "hide": 2,
        "includeAll": false,
        "label": "role_id",
        "multi": false,
        "name": "role_id",
        "options": [],
        "query": "select role_id from user_role where user_id = ${__user.id} and org_id = 1",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-15m",
    "to": "now"
  },
  "timepicker": {
    "hidden": false,
    "nowDelay": "",
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "browser",
  "title": "1.2. eXperDB Overview(chart)",
  "uid": "experdb-experdb-overview-chart",
  "version": 0,
  "weekStart": ""
}

temp

Clone this wiki locally