1 - APM Overview
APM Overview across all services.
APM Overview dashboard offered by Promscale on top of traces by leveraging SQL and TimescaleDB capabilities.

This dashboard contains from the last 30 mins :

1. **Services** describing service level metrics i.e. Requests rate, Average duration, p90 duration, and Error rate.
2. **Slowest Requests** describing Trace ID, Service, Operation. Timestamp and Duration.
3. **Most Common Errors** describing Error, Service, and Occurrences. 
{
  "__inputs": [
    {
      "name": "DS_PROMSCALE-SQL",
      "label": "Promscale-SQL",
      "description": "TimescaleDB as PostgreSQL data source",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__elements": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.5.2"
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "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": 0,
  "id": null,
  "links": [
    {
      "asDropdown": false,
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "promscale",
        "apm"
      ],
      "targetBlank": false,
      "title": "Menu",
      "tooltip": "",
      "type": "dashboards",
      "url": ""
    },
    {
      "asDropdown": false,
      "icon": "doc",
      "includeVars": false,
      "keepTime": false,
      "tags": [],
      "targetBlank": true,
      "title": "Documentation",
      "tooltip": "",
      "type": "link",
      "url": "https://docs.timescale.com/promscale/latest/"
    }
  ],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_PROMSCALE-SQL}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Requests"
            },
            "properties": [
              {
                "id": "unit",
                "value": "reqps"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Avg Duration"
            },
            "properties": [
              {
                "id": "unit",
                "value": "ms"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "p90 Duration"
            },
            "properties": [
              {
                "id": "unit",
                "value": "ms"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Error rate"
            },
            "properties": [
              {
                "id": "unit",
                "value": "percentunit"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Service"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Show service overview",
                    "url": "/d/YWfN6wL7z/?var-service=${__value.raw}"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 24,
        "w": 13,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": false,
            "displayName": "Avg Duration"
          }
        ]
      },
      "pluginVersion": "8.5.2",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_PROMSCALE-SQL}"
          },
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n    service_name AS \"Service\",\n    COUNT(*)::numeric / (30 * 60) AS \"Requests\",\n    AVG(duration_ms) AS \"Avg Duration\",\n    ROUND(approx_percentile(0.90, percentile_agg(duration_ms))::numeric, 3) AS \"p90 Duration\",\n    (count(*) filter (where status_code = 'error')::numeric / count(*)) AS \"Error rate\"\nFROM ps_trace.span s\nWHERE start_time > NOW() - INTERVAL '30m'\nAND (span_kind = 'server' OR parent_span_id is NULL)\nGROUP BY 1\nORDER BY 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "span_duration_ms"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "event",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Services (Last 30 minutes)",
      "type": "table"
    },
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_PROMSCALE-SQL}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Duration"
            },
            "properties": [
              {
                "id": "unit",
                "value": "ms"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "custom.width",
                "value": 143
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Trace ID"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 282
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": true,
                    "title": "View trace details",
                    "url": "/explore?left=%5B%22${__from}%22,%22${__to}%22,%22PC6F1FDB212D0F52B%22,%7B\"query\":\"${__value.raw}\"%7D%5D"
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "start_time"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 182
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Trace ID"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 94
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Service"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Show service overview",
                    "url": "/d/YWfN6wL7z/?var-service=${__value.raw}"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 12,
        "w": 11,
        "x": 13,
        "y": 0
      },
      "id": 4,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "8.5.2",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_PROMSCALE-SQL}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  replace(trace_id::text, '-'::text, ''::text) as \"Trace ID\",\n  service_name as \"Service\",\n  span_name as \"Operation\",\n  start_time as \"Time\",\n  duration_ms as \"Duration\" \nFROM ps_trace.span\nWHERE start_time > NOW() - INTERVAL '30m'\nAND parent_span_id is null\nORDER BY duration_ms DESC\nLIMIT 50\n;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "span_duration_ms"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "event",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Slowest Requests (last 30 minutes)",
      "type": "table"
    },
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_PROMSCALE-SQL}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Service"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Show service overview",
                    "url": "/d/YWfN6wL7z/?var-service=${__value.raw}"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 12,
        "w": 11,
        "x": 13,
        "y": 12
      },
      "id": 5,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "8.5.2",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_PROMSCALE-SQL}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  status_message as \"Error\",\n  service_name as \"Service\",\n  count(*) as \"Occurrences\" \nFROM ps_trace.span\nWHERE start_time > NOW() - INTERVAL '30m'\nAND status_code = 'error'\nGROUP BY 1, 2\nORDER BY 3\n;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "span_duration_ms"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "event",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Most Common Errors (last 30 minutes)",
      "type": "table"
    }
  ],
  "schemaVersion": 36,
  "style": "dark",
  "tags": [
    "promscale",
    "apm"
  ],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "hidden": true
  },
  "timezone": "",
  "title": "1 - APM Overview",
  "uid": "vBhEewLnk",
  "version": 1,
  "weekStart": "",
  "gnetId": 16242,
  "description": "APM Overview across all services."
}