{
  "tags": [],
  "title": "PostgreSQL Exporter",
  "widgets": [
    {
      "layout": {
        "x": 0,
        "y": 0,
        "width": 12,
        "height": 15
      },
      "definition": {
        "type": "group",
        "title": "Global Statistics",
        "widgets": [
          {
            "layout": {
              "x": 0,
              "y": 0,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "PostgreSQL Version",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "max:pg_settings_server_version_num{*}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 2,
              "y": 0,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Max Replication Lag",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "max:postgresql.replication_delay{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "s"
            }
          },
          {
            "layout": {
              "x": 4,
              "y": 0,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Active clients",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_activity_count{$Instance,state:active}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 0,
              "width": 2,
              "height": 2
            },
            "definition": {
              "type": "query_value",
              "title": "Shared Buffer Hits",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.buffer_hit{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.disk_read{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1 / (query1 + query2) * 100"
                    }
                  ],
                  "response_format": "scalar",
                  "conditional_formats": [
                    {
                      "value": 80,
                      "palette": "white_on_yellow",
                      "comparator": ">="
                    },
                    {
                      "value": 90,
                      "palette": "white_on_green",
                      "comparator": ">="
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "%"
            }
          },
          {
            "layout": {
              "x": 8,
              "y": 0,
              "width": 2,
              "height": 2
            },
            "definition": {
              "type": "query_value",
              "title": "Connections used",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.connections{*}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "max:postgresql.max_connections{*}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "(query1 / query2) * 100"
                    }
                  ],
                  "response_format": "scalar",
                  "conditional_formats": [
                    {
                      "value": 0.75,
                      "palette": "white_on_yellow",
                      "comparator": ">="
                    },
                    {
                      "value": 0.9,
                      "palette": "white_on_red",
                      "comparator": ">="
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "%"
            }
          },
          {
            "layout": {
              "x": 10,
              "y": 0,
              "width": 2,
              "height": 2
            },
            "definition": {
              "type": "query_value",
              "title": "Commit Ratio",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.commits{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rollbacks{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "(query1 / (query1 + query2)) * 100"
                    }
                  ],
                  "response_format": "scalar",
                  "conditional_formats": [
                    {
                      "value": 0.75,
                      "palette": "white_on_red",
                      "comparator": ">="
                    },
                    {
                      "value": 0.9,
                      "palette": "white_on_green",
                      "comparator": ">="
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "%"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 1,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "note",
              "content": "**PostgreSQL Uptime**\n\nUnsupported panel (singlestat)\n\n- time() - pg_postmaster_start_time_seconds cannot be expressed: no Datadog PostgreSQL uptime metric and time() is unavailable in formulas\n\nOriginal PromQL:\n```\nA: time()-(pg_postmaster_start_time_seconds{instance=\"$Instance\"})\n```",
              "tick_pos": "50%",
              "font_size": "14",
              "show_tick": false,
              "tick_edge": "left",
              "text_align": "left",
              "has_padding": true,
              "vertical_align": "top",
              "background_color": "white"
            }
          },
          {
            "layout": {
              "x": 2,
              "y": 1,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Transaction rate",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.commits{$Instance}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rollbacks{$Instance}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1 + query2"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 4,
              "y": 1,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Query rate",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_statements_calls.count{$Instance}.as_rate()",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 2,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Total database size",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.database_size{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "B"
            }
          },
          {
            "layout": {
              "x": 4,
              "y": 2,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Average query runtime",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_statements_total_time_seconds.count{$Instance}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:pg_stat_statements_calls.count{$Instance}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "diff(query1) / diff(query2)"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "s"
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 2,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Shared Buffers",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:pg_settings_shared_buffers_bytes{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "B"
            }
          },
          {
            "layout": {
              "x": 8,
              "y": 2,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Max Connections",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.max_connections{$Instance}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 3,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Connections by state (stacked)",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_activity_count{$Instance} by {state}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "bars",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 3,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Connections by database (stacked)",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_activity_count{$Instance} by {datname}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "bars",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 5,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Transactions",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.commits{*}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rollbacks{*}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "committed",
                      "formula": "query1"
                    },
                    {
                      "alias": "rollback",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 5,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Tuples inserts/updates/deletes",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.rows_inserted{$Instance}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rows_updated{$Instance}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query3",
                      "query": "sum:postgresql.rows_deleted{$Instance}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "Inserts",
                      "formula": "query1"
                    },
                    {
                      "alias": "Updates",
                      "formula": "query2"
                    },
                    {
                      "alias": "Deletes",
                      "formula": "query3"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 7,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "I/O Read/Write time",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_database_blk_read_time.count{$Instance}.as_rate()",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:pg_stat_database_blk_write_time.count{$Instance}.as_rate()",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "blk_read_time",
                      "formula": "query1"
                    },
                    {
                      "alias": "blk_read_time",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 7,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Tuples fetched/returned",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.rows_fetched{$Instance}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rows_returned{$Instance}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "Fetched",
                      "formula": "query1"
                    },
                    {
                      "alias": "Returned",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 9,
              "width": 6,
              "height": 3
            },
            "definition": {
              "type": "timeseries",
              "title": "Locks by state",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.locks{$Instance} by {lock_mode}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 9,
              "width": 6,
              "height": 1
            },
            "definition": {
              "type": "timeseries",
              "title": "Deadlocks by database",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.deadlocks{$Instance} by {db}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 10,
              "width": 6,
              "height": 1
            },
            "definition": {
              "type": "timeseries",
              "title": "Temporary files by database",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.temp_files{$Instance} by {db}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 12,
              "width": 6,
              "height": 3
            },
            "definition": {
              "type": "timeseries",
              "title": "Replication lag ",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "max:postgresql.replication_delay{$Instance}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "lag ",
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          }
        ],
        "show_title": true,
        "layout_type": "ordered"
      }
    },
    {
      "layout": {
        "x": 0,
        "y": 15,
        "width": 12,
        "height": 9
      },
      "definition": {
        "type": "group",
        "title": "Database: $Database",
        "widgets": [
          {
            "layout": {
              "x": 0,
              "y": 0,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Active clients",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:pg_stat_activity_count{$Instance,state:active,$Database}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 2,
              "y": 0,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Database size",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.database_size{$Instance,db:$Database.value}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "B"
            }
          },
          {
            "layout": {
              "x": 4,
              "y": 0,
              "width": 2,
              "height": 2
            },
            "definition": {
              "type": "query_value",
              "title": "Shared Buffer Hits",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.buffer_hit{$Instance,db:$Database.value}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:postgresql.disk_read{$Instance,db:$Database.value}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "(query1 / (query1 + query2)) * 100"
                    }
                  ],
                  "response_format": "scalar",
                  "conditional_formats": [
                    {
                      "value": 0.8,
                      "palette": "white_on_yellow",
                      "comparator": ">="
                    },
                    {
                      "value": 0.9,
                      "palette": "white_on_green",
                      "comparator": ">="
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "%"
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 0,
              "width": 2,
              "height": 2
            },
            "definition": {
              "type": "query_value",
              "title": "Commit Ratio",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.commits{$Instance,db:$Database.value}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:postgresql.rollbacks{$Instance,db:$Database.value}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "(query1 / (query1 + query2)) * 100"
                    }
                  ],
                  "response_format": "scalar",
                  "conditional_formats": [
                    {
                      "value": 0.75,
                      "palette": "white_on_red",
                      "comparator": ">="
                    },
                    {
                      "value": 0.9,
                      "palette": "white_on_green",
                      "comparator": ">="
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "%"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 1,
              "width": 2,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Transaction rate",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.commits{$Instance,db:$Database.value}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:postgresql.rollbacks{$Instance,db:$Database.value}",
                      "aggregator": "avg",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1 + query2"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 2,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Connections by state (stacked)",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:pg_stat_activity_count{$Instance,$Database} by {state}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "bars",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 2,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Transactions",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.commits{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:postgresql.rollbacks{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "committed",
                      "formula": "query1"
                    },
                    {
                      "alias": "rollback",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 4,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Tuples inserts/updates/deletes",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.rows_inserted{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:postgresql.rows_updated{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query3",
                      "query": "avg:postgresql.rows_deleted{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "Inserts",
                      "formula": "query1"
                    },
                    {
                      "alias": "Updates",
                      "formula": "query2"
                    },
                    {
                      "alias": "Deletes",
                      "formula": "query3"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 4,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Tuples fetched/returned",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.rows_fetched{$Instance,db:$Database.value}",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:postgresql.rows_returned{$Instance,$Database}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "Fetched",
                      "formula": "query1"
                    },
                    {
                      "alias": "Returned",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 6,
              "width": 6,
              "height": 3
            },
            "definition": {
              "type": "timeseries",
              "title": "Locks by state",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:postgresql.locks{$Instance,$Database} by {lock_mode}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 6,
              "width": 6,
              "height": 1
            },
            "definition": {
              "type": "timeseries",
              "title": "Deadlocks by database",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.deadlocks{$Instance,$Database}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "deadlocks",
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 7,
              "width": 6,
              "height": 1
            },
            "definition": {
              "type": "timeseries",
              "title": "Temporary files by database",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": true
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:postgresql.temp_files{$Instance,$Database}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "temp_files",
                      "formula": "query1"
                    }
                  ],
                  "display_type": "area",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          }
        ],
        "show_title": true,
        "layout_type": "ordered"
      }
    }
  ],
  "description": "Converted from Grafana dashboard https://grafana.com/grafana/dashboards/12485 (by egmont1227). postgres exporter Dashboard for display important postgreSQL metric",
  "layout_type": "ordered",
  "reflow_type": "fixed",
  "template_variables": [
    {
      "name": "Instance",
      "prefix": "host",
      "default": "*",
      "available_values": []
    },
    {
      "name": "Database",
      "prefix": "db",
      "default": "*",
      "available_values": []
    }
  ]
}