{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "DS_TEMPO",
      "label": "Tempo",
      "description": "",
      "type": "datasource",
      "pluginId": "tempo",
      "pluginName": "Tempo"
    },
    {
      "name": "DS_LOKI",
      "label": "Loki",
      "description": "",
      "type": "datasource",
      "pluginId": "loki",
      "pluginName": "Loki"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "11.1.4"
    },
    {
      "type": "panel",
      "id": "logs",
      "name": "Logs",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "loki",
      "name": "Loki",
      "version": "1.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "tempo",
      "name": "Tempo",
      "version": "11.1.4"
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "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": 0,
  "id": null,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 33,
      "panels": [],
      "title": "Overview",
      "type": "row"
    },
    {
      "gridPos": {
        "h": 9,
        "w": 7,
        "x": 0,
        "y": 1
      },
      "id": 32,
      "options": {
        "code": {
          "language": "plaintext",
          "showLineNumbers": false,
          "showMiniMap": false
        },
        "content": "<p style=\"text-align: center\">\n  <img alt=\"CloudQueryLogo\" src=\"https://docs.cloudquery.io/images/brand-logo/cloudquery_logo_png_dark_background.png\" />\n</p>\n\nUse this dashboard to get insights into CloudQuery syncs and optimize them. For more information on setting up CloudQuery with Grafana, see the [CloudQuery documentation](https://docs.cloudquery.io//docs/managing-cloudquery/monitoring/otel-grafana).\n\n## Links\n\n- [Home](https://www.cloudquery.io/)\n- [Download CLI](https://www.cloudquery.io/download)\n- [Register](https://www.cloudquery.io/auth/register)\n- [Pricing](https://www.cloudquery.io/pricing)",
        "mode": "markdown"
      },
      "pluginVersion": "11.1.4",
      "type": "text"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "inspect": false
          },
          "displayName": "${__field.labels.sync_table_name}",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "__systemRef": "hideSeriesFrom",
            "matcher": {
              "id": "byNames",
              "options": {
                "mode": "exclude",
                "names": [
                  "{__name__=\"sync_table_resources_total\", exported_job=\"cloudquery-aws\", instance=\"collector:8090\", job=\"opentelemetry\", sync_client_id=\"615713231484:ap-northeast-1\", sync_table_name=\"aws_s3_bucket_encryption_rules\"}"
                ],
                "prefix": "All except:",
                "readOnly": true
              }
            },
            "properties": []
          }
        ]
      },
      "gridPos": {
        "h": 9,
        "w": 9,
        "x": 7,
        "y": 1
      },
      "id": 26,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": ["sum"],
          "show": false
        },
        "frameIndex": 211,
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Resources"
          }
        ]
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "expr": "sum(sync_table_resources_total{exported_job=~\"cloudquery-.*$plugin.*\", sync_table_name=~\".*$table.*\", sync_client_id=~\".*$clientid.*\"}) by (sync_table_name)",
          "format": "table",
          "fullMetaSearch": false,
          "includeNullMetadata": false,
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "Total resources by table",
      "transformations": [
        {
          "id": "sortBy",
          "options": {
            "fields": {},
            "sort": [
              {
                "desc": true,
                "field": "Time"
              }
            ]
          }
        },
        {
          "id": "partitionByValues",
          "options": {
            "fields": ["sync_table_name"],
            "keepFields": false
          }
        },
        {
          "id": "limit",
          "options": {
            "limitField": 1
          }
        },
        {
          "id": "joinByLabels",
          "options": {
            "value": "sync_table_name"
          }
        },
        {
          "id": "reduce",
          "options": {
            "labelsToFields": false,
            "reducers": ["lastNotNull"]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "includeByName": {},
            "indexByName": {},
            "renameByName": {
              "Field": "Table",
              "Last *": "Resources"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "inspect": false
          },
          "displayName": "${__field.labels.sync_table_name}",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "__systemRef": "hideSeriesFrom",
            "matcher": {
              "id": "byNames",
              "options": {
                "mode": "exclude",
                "names": [
                  "{__name__=\"sync_table_resources_total\", exported_job=\"cloudquery-aws\", instance=\"collector:8090\", job=\"opentelemetry\", sync_client_id=\"615713231484:ap-northeast-1\", sync_table_name=\"aws_s3_bucket_encryption_rules\"}"
                ],
                "prefix": "All except:",
                "readOnly": true
              }
            },
            "properties": []
          }
        ]
      },
      "gridPos": {
        "h": 9,
        "w": 8,
        "x": 16,
        "y": 1
      },
      "id": 29,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": ["sum"],
          "show": false
        },
        "frameIndex": 211,
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Errors"
          }
        ]
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "expr": "sum(sync_table_errors_total{exported_job=~\"cloudquery-.*$plugin.*\", sync_table_name=~\".*$table.*\", sync_client_id=~\".*$clientid.*\"}) by (sync_table_name)",
          "format": "table",
          "fullMetaSearch": false,
          "includeNullMetadata": false,
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "Total errors by table",
      "transformations": [
        {
          "id": "sortBy",
          "options": {
            "fields": {},
            "sort": [
              {
                "desc": true,
                "field": "Time"
              }
            ]
          }
        },
        {
          "id": "partitionByValues",
          "options": {
            "fields": ["sync_table_name"],
            "keepFields": false
          }
        },
        {
          "id": "limit",
          "options": {
            "limitField": 1
          }
        },
        {
          "id": "joinByLabels",
          "options": {
            "value": "sync_table_name"
          }
        },
        {
          "id": "reduce",
          "options": {
            "labelsToFields": false,
            "reducers": ["lastNotNull"]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "includeByName": {},
            "indexByName": {},
            "renameByName": {
              "Field": "Table",
              "Last *": "Errors"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 10
      },
      "id": 17,
      "panels": [],
      "title": "Performance",
      "type": "row"
    },
    {
      "datasource": {
        "type": "tempo",
        "uid": "${DS_TEMPO}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 100,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 11
      },
      "id": 14,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": false
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "tempo",
            "uid": "${DS_TEMPO}"
          },
          "filters": [
            {
              "id": "d894dd32",
              "operator": "=",
              "scope": "span"
            }
          ],
          "limit": 20,
          "query": "{span.sync.client.id=~\".*$clientid.*\" && resource.service.name=~\"cloudquery-.*$plugin.*\" && name=~\"sync.table.*$table.*\"} | quantile_over_time(duration, 0.95) by (name)",
          "queryType": "traceql",
          "refId": "A",
          "spss": 3,
          "tableType": "spans"
        }
      ],
      "title": "Slowest tables over time (p95)",
      "transformations": [
        {
          "id": "labelsToFields",
          "options": {
            "keepLabels": ["name"],
            "mode": "columns",
            "valueLabel": "name"
          }
        },
        {
          "id": "renameByRegex",
          "options": {
            "regex": "\"sync.table.(.*)\"",
            "renamePattern": "$1"
          }
        },
        {
          "id": "convertFieldType",
          "options": {
            "conversions": [],
            "fields": {}
          }
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "tempo",
        "uid": "${DS_TEMPO}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto",
              "wrapText": false
            },
            "filterable": false,
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Table"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 351
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 11
      },
      "id": 1,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": ["sum"],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Duration"
          }
        ]
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "tempo",
            "uid": "${DS_TEMPO}"
          },
          "filters": [
            {
              "id": "1b3d0e9e",
              "operator": "=~",
              "scope": "span",
              "tag": "sync.client.id",
              "value": ["\".*clientid.*\""]
            },
            {
              "id": "service-name",
              "operator": "=~",
              "scope": "resource",
              "tag": "service.name",
              "value": ["\"cloudquery-.*$plugin.*\""]
            },
            {
              "id": "span-name",
              "operator": "=~",
              "scope": "span",
              "tag": "name",
              "value": ["\".*$table.*\""]
            }
          ],
          "limit": 20,
          "query": "{span.sync.client.id=~\".*$clientid.*\" && resource.service.name=~\"cloudquery-.*$plugin.*\" && name=~\"sync.table.*$table.*\"}",
          "queryType": "traceql",
          "refId": "A",
          "tableType": "spans"
        }
      ],
      "title": "Tables By Sync Duration",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Span ID": true,
              "Start time": true,
              "Trace Name": true,
              "Trace Service": true,
              "traceIdHidden": true
            },
            "includeByName": {},
            "indexByName": {
              "Duration": 7,
              "Name": 1,
              "Span ID": 6,
              "Start time": 8,
              "Trace Name": 5,
              "Trace Service": 4,
              "service.name": 0,
              "sync.client.id": 2,
              "traceIdHidden": 3
            },
            "renameByName": {
              "Name": "Table",
              "Span ID": "",
              "Trace Name": "",
              "service.name": "Plugin",
              "sync.client.id": "Client ID",
              "traceIdHidden": ""
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "tempo",
        "uid": "${DS_TEMPO}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 100,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 21
      },
      "id": 11,
      "maxPerRow": 3,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": false
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "repeat": "plugin",
      "repeatDirection": "h",
      "targets": [
        {
          "datasource": {
            "type": "tempo",
            "uid": "${DS_TEMPO}"
          },
          "limit": 20,
          "query": "{resource.service.name=~\"cloudquery-.*$plugin.*\" && name=\"sync\"}",
          "queryType": "traceql",
          "refId": "A",
          "tableType": "traces"
        }
      ],
      "title": "Sync Time Over Time For Plugin ($plugin)",
      "type": "timeseries"
    },
    {
      "collapsed": true,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 29
      },
      "id": 10,
      "panels": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_LOKI}"
          },
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 3
          },
          "id": 6,
          "options": {
            "dedupStrategy": "none",
            "enableLogDetails": true,
            "prettifyLogMessage": false,
            "showCommonLabels": false,
            "showLabels": false,
            "showTime": false,
            "sortOrder": "Descending",
            "wrapLogMessage": false
          },
          "targets": [
            {
              "datasource": {
                "type": "loki",
                "uid": "${DS_LOKI}"
              },
              "editorMode": "code",
              "expr": "{job=~\"cloudquery-.*$plugin.*\"} | json | attributes_client =~ `.*$clientid.*` | attributes_table =~ `.*$table.*`",
              "key": "Q-a008a9ea-c9d3-4018-ac3e-891f19983135-0",
              "queryType": "range",
              "refId": "A"
            }
          ],
          "title": "Logs",
          "type": "logs"
        }
      ],
      "title": "Logs",
      "type": "row"
    }
  ],
  "refresh": "",
  "schemaVersion": 39,
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": ".*",
        "current": {},
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "label_values(exported_job)",
        "hide": 0,
        "includeAll": true,
        "label": "Plugin",
        "multi": true,
        "name": "plugin",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(exported_job)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "/cloudquery-(?<value>.+)/",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      },
      {
        "allValue": ".*",
        "current": {},
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "label_values(sync_table_name)",
        "hide": 0,
        "includeAll": true,
        "label": "Table",
        "multi": true,
        "name": "table",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(sync_table_name)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": ".*",
        "current": {},
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "label_values(sync_client_id)",
        "hide": 0,
        "includeAll": true,
        "label": "Client ID",
        "multi": true,
        "name": "clientid",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(sync_client_id)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "CloudQuery Dashboard",
  "uid": "6_bNYpGVz",
  "version": 106,
  "weekStart": ""
}
