{
  "__inputs": [
    {
      "name": "DS_INFINITY",
      "label": "Infinity",
      "type": "datasource",
      "pluginId": "yesoreyeram-infinity-datasource",
      "pluginName": "Infinity"
    }
  ],
  "__requires": [
    {
      "type": "datasource",
      "id": "yesoreyeram-infinity-datasource",
      "name": "Infinity",
      "version": "3.0.0"
    }
  ],
  "title": "Gurubase Siper (Infinity)",
  "uid": "gurubase-gateway-infinity",
  "tags": [
    "gurubase"
  ],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "graphTooltip": 1,
  "refresh": "1m",
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "templating": {
    "list": [
      {
        "name": "datasource",
        "label": "Data source",
        "type": "datasource",
        "query": "yesoreyeram-infinity-datasource",
        "current": {},
        "hide": 0
      },
      {
        "name": "panel_url",
        "label": "Panel address",
        "type": "textbox",
        "query": "https://panel.example.com",
        "current": {
          "text": "https://panel.example.com",
          "value": "https://panel.example.com"
        },
        "hide": 0
      },
      {
        "name": "window",
        "label": "Window",
        "type": "custom",
        "query": "1h,6h,24h,7d,30d",
        "current": {
          "text": "24h",
          "value": "24h"
        },
        "options": [
          {
            "text": "1h",
            "value": "1h",
            "selected": false
          },
          {
            "text": "6h",
            "value": "6h",
            "selected": false
          },
          {
            "text": "24h",
            "value": "24h",
            "selected": true
          },
          {
            "text": "7d",
            "value": "7d",
            "selected": false
          },
          {
            "text": "30d",
            "value": "30d",
            "selected": false
          }
        ],
        "hide": 0
      }
    ]
  },
  "annotations": {
    "list": []
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Requests (window)",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "requests",
              "text": "Requests",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "value",
        "graphMode": "area",
        "textMode": "auto"
      }
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Failed requests (window)",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 6,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "errors",
              "text": "Failed",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "value",
        "graphMode": "area",
        "textMode": "auto"
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Masked characters (window)",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "input_chars",
              "text": "Characters",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "value",
        "graphMode": "area",
        "textMode": "auto"
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Data age",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 18,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "table",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "",
          "columns": [
            {
              "selector": "last_ingest_age_seconds",
              "text": "Age",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 120
              },
              {
                "color": "red",
                "value": 300
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "value",
        "graphMode": "area",
        "textMode": "auto"
      },
      "description": "Seconds since the data was refreshed. Above a few minutes means the data is stale, not that traffic stopped."
    },
    {
      "id": 5,
      "type": "timeseries",
      "title": "Requests and failures",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 4,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "requests",
              "text": "Requests",
              "type": "number"
            },
            {
              "selector": "errors",
              "text": "Failed",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Requests"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "blue"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Failed"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "red"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 6,
      "type": "timeseries",
      "title": "Tokens",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 4,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "input_tokens",
              "text": "Input",
              "type": "number"
            },
            {
              "selector": "output_tokens",
              "text": "Output",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Input"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "blue"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Output"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "orange"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 7,
      "type": "timeseries",
      "title": "Masking",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 12,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "timeseries",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "window.points",
          "columns": [
            {
              "selector": "ts",
              "text": "Time",
              "type": "timestamp"
            },
            {
              "selector": "input_chars",
              "text": "Characters",
              "type": "number"
            },
            {
              "selector": "masked_entities",
              "text": "Entities",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Characters"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "blue"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Entities"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "purple"
                }
              },
              {
                "id": "custom.axisPlacement",
                "value": "right"
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 8,
      "type": "table",
      "title": "Response time by key and model (since gateway start)",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 12,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "table",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "latency",
          "columns": [
            {
              "selector": "key_id",
              "text": "Key id",
              "type": "string"
            },
            {
              "selector": "model",
              "text": "Model",
              "type": "string"
            },
            {
              "selector": "count",
              "text": "Calls",
              "type": "number"
            },
            {
              "selector": "p50_seconds",
              "text": "p50 (s)",
              "type": "number"
            },
            {
              "selector": "p95_seconds",
              "text": "p95 (s)",
              "type": "number"
            },
            {
              "selector": "p99_seconds",
              "text": "p99 (s)",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "description": "Successful LLM calls. Percentiles are estimated from a histogram.",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "indexByName": {
              "Key id": 0,
              "Model": 1,
              "Calls": 2,
              "p50 (s)": 3,
              "p95 (s)": 4,
              "p99 (s)": 5
            }
          }
        }
      ]
    },
    {
      "id": 9,
      "type": "table",
      "title": "Lifetime totals by key and model",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 20,
        "w": 24,
        "h": 7
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "table",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "llm",
          "columns": [
            {
              "selector": "key_id",
              "text": "Key id",
              "type": "string"
            },
            {
              "selector": "model",
              "text": "Model",
              "type": "string"
            },
            {
              "selector": "requests_2xx",
              "text": "Succeeded",
              "type": "number"
            },
            {
              "selector": "requests_4xx",
              "text": "4xx",
              "type": "number"
            },
            {
              "selector": "requests_429_key_limit",
              "text": "429 key limit",
              "type": "number"
            },
            {
              "selector": "requests_429_provider",
              "text": "429 provider",
              "type": "number"
            },
            {
              "selector": "requests_5xx",
              "text": "5xx",
              "type": "number"
            },
            {
              "selector": "requests_other",
              "text": "Other",
              "type": "number"
            },
            {
              "selector": "input_tokens",
              "text": "Input tokens",
              "type": "number"
            },
            {
              "selector": "output_tokens",
              "text": "Output tokens",
              "type": "number"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "transformations": [
        {
          "id": "organize",
          "options": {
            "indexByName": {
              "Key id": 0,
              "Model": 1,
              "Succeeded": 2,
              "4xx": 3,
              "429 key limit": 4,
              "429 provider": 5,
              "5xx": 6,
              "Other": 7,
              "Input tokens": 8,
              "Output tokens": 9
            }
          }
        }
      ]
    },
    {
      "id": 10,
      "type": "table",
      "title": "API keys",
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 27,
        "w": 24,
        "h": 6
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${datasource}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "table",
          "url": "${panel_url}/api/v1/usage",
          "url_options": {
            "method": "GET",
            "params": [
              {
                "key": "window",
                "value": "${window}"
              }
            ]
          },
          "root_selector": "keys",
          "columns": [
            {
              "selector": "key_id",
              "text": "Key id",
              "type": "string"
            },
            {
              "selector": "key_name",
              "text": "Name",
              "type": "string"
            }
          ],
          "filters": []
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "transformations": [
        {
          "id": "organize",
          "options": {
            "indexByName": {
              "Key id": 0,
              "Name": 1
            }
          }
        }
      ]
    }
  ]
}