@perses-dev/greptimedb-plugin 0.2.0-beta.2 → 0.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{GreptimeDB.f1e3a072.js → GreptimeDB.773599af.js} +5 -5
- package/__mf/js/async/{121.caec175a.js → 121.f4758b1a.js} +2 -2
- package/__mf/js/async/{562.15460f81.js → 181.b5d8e574.js} +2 -2
- package/__mf/js/async/{192.b9279059.js → 192.07b63093.js} +1 -1
- package/__mf/js/async/{2.dbc0a9c4.js → 2.4cd2539d.js} +1 -1
- package/__mf/js/async/{235.7a774edc.js → 235.f17c4d1f.js} +1 -1
- package/__mf/js/async/{274.d5a294d9.js → 274.43c94923.js} +2 -2
- package/__mf/js/async/356.7e74f3c4.js +1 -0
- package/__mf/js/async/{392.201e515e.js → 392.6e30bf0d.js} +2 -2
- package/__mf/js/async/{43.ebbb8652.js → 43.6fa2fd49.js} +2 -2
- package/__mf/js/async/{440.f6c55d74.js → 440.8ad042c6.js} +2 -2
- package/__mf/js/async/{45.04388bc3.js → 45.733e3506.js} +1 -1
- package/__mf/js/async/{470.f896cf06.js → 470.5f6a0ccf.js} +2 -2
- package/__mf/js/async/{496.91780bef.js → 496.7651ac66.js} +1 -1
- package/__mf/js/async/{529.6c76a9cd.js → 529.52c2eed5.js} +5 -5
- package/__mf/js/async/{181.d4d87a1f.js → 562.61c2a694.js} +2 -2
- package/__mf/js/async/587.1ec52589.js +1 -0
- package/__mf/js/async/{588.2c301420.js → 588.479e2efe.js} +1 -1
- package/__mf/js/async/{616.ef1089bf.js → 616.b372a284.js} +1 -1
- package/__mf/js/async/{71.9f52cdd7.js → 71.5fe92f42.js} +1 -1
- package/__mf/js/async/{77.51ac6fa8.js → 77.12e137c9.js} +1 -1
- package/__mf/js/async/{862.d29af04f.js → 862.dcf75db6.js} +2 -2
- package/__mf/js/async/{873.d5028ea7.js → 873.1cbf0072.js} +1 -1
- package/__mf/js/async/890.3e590d2e.js +102 -0
- package/__mf/js/async/{941.6221d54d.js → 941.b9c4790b.js} +2 -2
- package/__mf/js/async/{944.89173f4a.js → 944.57e277f4.js} +2 -2
- package/__mf/js/async/968.266d3d0b.js +1 -0
- package/__mf/js/async/{978.4589faec.js → 978.68177f81.js} +1 -1
- package/__mf/js/async/985.120ee5c0.js +52 -0
- package/__mf/js/async/{__federation_expose_GreptimeDBDatasource.ec9b176f.js → __federation_expose_GreptimeDBDatasource.8cf38268.js} +2 -2
- package/__mf/js/async/{__federation_expose_GreptimeDBLogQuery.96bef921.js → __federation_expose_GreptimeDBLogQuery.e8a7a44c.js} +3 -3
- package/__mf/js/async/{__federation_expose_GreptimeDBTimeSeriesQuery.f4171877.js → __federation_expose_GreptimeDBTimeSeriesQuery.02b0ffbc.js} +3 -3
- package/__mf/js/async/{__federation_expose_GreptimeDBTraceQuery.e0ffd686.js → __federation_expose_GreptimeDBTraceQuery.c403854b.js} +3 -3
- package/__mf/js/{main.993845fa.js → main.f1dde4da.js} +5 -5
- package/mf-manifest.json +67 -67
- package/mf-stats.json +67 -67
- package/package.json +8 -8
- package/__mf/js/async/186.c1dea752.js +0 -102
- package/__mf/js/async/356.21b667a3.js +0 -1
- package/__mf/js/async/587.445bbdb5.js +0 -1
- package/__mf/js/async/628.6ea4a812.js +0 -3
- package/__mf/js/async/968.6f0ebddf.js +0 -1
- /package/__mf/js/async/{121.caec175a.js.LICENSE.txt → 121.f4758b1a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{181.d4d87a1f.js.LICENSE.txt → 181.b5d8e574.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.d5a294d9.js.LICENSE.txt → 274.43c94923.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.201e515e.js.LICENSE.txt → 392.6e30bf0d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{43.ebbb8652.js.LICENSE.txt → 43.6fa2fd49.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{440.f6c55d74.js.LICENSE.txt → 440.8ad042c6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.f896cf06.js.LICENSE.txt → 470.5f6a0ccf.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{529.6c76a9cd.js.LICENSE.txt → 529.52c2eed5.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{562.15460f81.js.LICENSE.txt → 562.61c2a694.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{862.d29af04f.js.LICENSE.txt → 862.dcf75db6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.6221d54d.js.LICENSE.txt → 941.b9c4790b.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{944.89173f4a.js.LICENSE.txt → 944.57e277f4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_GreptimeDBDatasource.ec9b176f.js.LICENSE.txt → __federation_expose_GreptimeDBDatasource.8cf38268.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_GreptimeDBLogQuery.96bef921.js.LICENSE.txt → __federation_expose_GreptimeDBLogQuery.e8a7a44c.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_GreptimeDBTimeSeriesQuery.f4171877.js.LICENSE.txt → __federation_expose_GreptimeDBTimeSeriesQuery.02b0ffbc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_GreptimeDBTraceQuery.e0ffd686.js.LICENSE.txt → __federation_expose_GreptimeDBTraceQuery.c403854b.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_GreptimeDBDatasource.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_GreptimeDBDatasource.8cf38268.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_GreptimeDB_0_2_0_beta_3=self.chunk_GreptimeDB_0_2_0_beta_3||[]).push([["752"],{2192(e,t,r){var o=r(70451),i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var o,n={},u=null,c=null;for(o in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)a.call(t,o)&&!l.hasOwnProperty(o)&&(n[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===n[o]&&(n[o]=t[o]);return{$$typeof:i,type:e,key:u,ref:c,props:n,_owner:s.current}}t.Fragment=n,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},26599(e,t,r){async function o(e){var t;let r=null==(t=e.headers)?void 0:t.get("content-type");if(r&&r.includes("application/json")){let t=await e.json();return`GreptimeDB error: ${e.status} ${e.statusText} - ${JSON.stringify(t)}`}let o=await e.text();return`GreptimeDB error: ${e.status} ${e.statusText} - ${o}`}async function i(e,t){var r;let i,{datasourceUrl:n,headers:a}=t,s=(i=(r=n).endsWith("/")?`${r}v1/sql`:`${r}/v1/sql`).startsWith("http://")||i.startsWith("https://")?new URL(i):new URL(i,window.location.origin);if(!e.query)throw Error("No query provided in params");let l={method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a},body:new URLSearchParams({sql:e.query}).toString()};try{let e=await fetch(s.toString(),l);if(!e.ok){let t=await o(e);return console.error("GreptimeDB error response:",t),{status:"error",data:{output:[]},error:t}}let t=await e.json();return{status:(null==t?void 0:t.status)??"success",data:t}}catch(e){throw Error(`GreptimeDB query failed: ${e}`,{cause:e})}}r.r(t),r.d(t,{GreptimeDBDatasource:()=>l,GreptimeDBDatasourceEditor:()=>s});var n=r(62540),a=r(23724);function s(e){let{value:t,onChange:r,isReadonly:o}=e;return(0,n.jsx)(a.HTTPSettingsEditor,{value:t,onChange:r,isReadonly:o,initialSpecDirect:{directUrl:""},initialSpecProxy:{proxy:{kind:"HTTPProxy",spec:{allowedEndpoints:[{endpointPattern:"/v1/sql",method:"POST"}],url:""}}}})}let l={createClient:(e,t)=>{let{directUrl:r,headers:o,proxy:n}=e,{proxyUrl:a}=t,s=r??a;if(void 0===s)throw Error("No URL specified for GreptimeDBDatasource client. You can use directUrl in the spec to configure it.");let l={...null==n?void 0:n.spec.headers,...o};return{options:{datasourceUrl:s},query:(e,t)=>i(e,{datasourceUrl:s,headers:t??l})}},OptionsEditorComponent:s,createInitialOptions:()=>({directUrl:""})}}}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_GreptimeDBLogQuery.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_GreptimeDBLogQuery.e8a7a44c.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_GreptimeDB_0_2_0_beta_3=self.chunk_GreptimeDB_0_2_0_beta_3||[]).push([["396"],{2192(e,t,r){var n=r(70451),a=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var n,i={},s=null,d=null;for(n in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!u.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===i[n]&&(i[n]=t[n]);return{$$typeof:a,type:e,key:s,ref:d,props:i,_owner:l.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
|
|
3
3
|
SELECT
|
|
4
4
|
date_bin(INTERVAL '1 minute', ts) as ts,
|
|
5
5
|
avg(cpu_usage) as avg_cpu,
|
|
@@ -18,4 +18,4 @@ SELECT
|
|
|
18
18
|
FROM application_logs
|
|
19
19
|
WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
|
|
20
20
|
ORDER BY ts DESC
|
|
21
|
-
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),a=r(41865),i=r(56599),o=r(315),l=r(54227),u=r(29068);function s(e){let t=(0,i.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(l.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[a.Lz.lineWrapping,a.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>a});let n="GreptimeDBDatasource",a={kind:n}},64279(e,t,r){r.r(t),r.d(t,{GreptimeDBLogQuery:()=>_,GreptimeDBLogQueryEditor:()=>g,getGreptimeDBLogData:()=>o});var n=r(
|
|
21
|
+
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),a=r(41865),i=r(56599),o=r(315),l=r(54227),u=r(29068);function s(e){let t=(0,i.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(l.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[a.Lz.lineWrapping,a.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>a});let n="GreptimeDBDatasource",a={kind:n}},64279(e,t,r){r.r(t),r.d(t,{GreptimeDBLogQuery:()=>_,GreptimeDBLogQueryEditor:()=>g,getGreptimeDBLogData:()=>o});var n=r(23724),a=r(7140),i=r(57748);let o=async(e,t)=>{if(!e.query)return{logs:{entries:[],totalCount:0},timeRange:{start:t.timeRange.start,end:t.timeRange.end}};let{start:r,end:n}=t.timeRange,o=(0,i.EY)(e.query,t.variableState,t.timeRange),l=await t.datasourceStore.getDatasourceClient(e.datasource??a.S),u=await l.query({start:r.getTime().toString(),end:n.getTime().toString(),query:o});if("error"===u.status)throw Error(u.error??"GreptimeDB query failed");return{timeRange:{start:r,end:n},logs:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{entries:[],totalCount:0};let a=(0,i.nu)(r);if(-1===a)return{entries:[],totalCount:0};let o=n.map(e=>{var t;let n=(0,i.W0)(null==e?void 0:e[a],null==(t=r[a])?void 0:t.data_type);if(null===n)return null;let o={},l=[];return r.forEach((t,r)=>{if(r===a)return;let n=null==e?void 0:e[r],i=null==n?"":String(n);o[t.name]=i,l.push(`${t.name}=${""===i?"--":i}`)}),{timestamp:Math.floor(n/1e3),labels:o,line:l.join(" ")}}).filter(e=>null!==e);return{entries:o,totalCount:o.length}}((0,i.qV)(u.data)),metadata:{executedQueryString:o}}};var l=r(62540),u=r(56599),s=r(315),d=r(38662),m=r(70451),p=r(71122),c=r(15062),f=r(64383);function g(e){let t=(0,u.A)(),{onChange:r,value:i}=e,{datasource:o}=i,g=o??a.S,{query:_,handleQueryChange:y,handleQueryBlur:h}=(0,f.Z)(e),v=(0,m.useCallback)(e=>{y(e)},[y]),x={fontSize:"11px",color:t.palette.text.secondary,backgroundColor:t.palette.background.code,padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"};return(0,l.jsxs)(s.A,{spacing:1.5,children:[(0,l.jsx)(n.DatasourceSelect,{datasourcePluginKind:a.N,value:g,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===a.N)return void r((0,d.produce)(i,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,l.jsx)(p.M,{value:_,onChange:v,onBlur:h,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),r((0,d.produce)(i,e=>{e.query=_})))},placeholder:"Enter GreptimeDB SQL query"}),(0,l.jsxs)("details",{children:[(0,l.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:t.palette.text.secondary,marginBottom:"8px"},children:"Query Examples"}),(0,l.jsx)("div",{style:x,children:c.t})]})]})}let _={getLogData:o,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,n.parseVariables)(e.query))]})}},57748(e,t,r){r.d(t,{EY:()=>a,W0:()=>function e(t,r){if(null==t)return null;let n=i(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let a=new Date(t).getTime();return Number.isNaN(a)?null:a},nu:()=>l,qV:()=>o});var n=r(23724);function a(e,t,r){let a,i,o,l,u,{start:s,end:d}=r,m=d.valueOf()-s.valueOf(),p={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:d.valueOf().toString(),loading:!1},__range_ms:{value:m.toString(),loading:!1},__range_s:{value:Math.floor(m/1e3).toString(),loading:!1},__range:{value:(i=Math.floor((a=Math.floor(m/1e3))/3600),o=Math.floor(a%3600/60),l=a%60,u="",i>0&&(u+=`${i}h`),o>0&&(u+=`${o}m`),(l>0||""===u)&&(u+=`${l}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...p,...t})}function i(e){return e?e.toLowerCase():null}function o(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function l(e){let t=-1,r=e.filter(e=>{let t=i(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=new Set(["greptime_timestamp","timestamp","ts","time"]);t=e.findIndex(e=>r.has(e.name.toLowerCase()))}return t}},64383(e,t,r){r.d(t,{Z:()=>i});var n=r(38662),a=r(70451);function i(e){let{onChange:t,value:r}=e,[i,o]=(0,a.useState)(r.query||""),[l,u]=(0,a.useState)(r.query);return r.query!==l&&(o(r.query||""),u(r.query)),{query:i,handleQueryChange:e=>{o(e)},handleQueryBlur:()=>{u(i),t((0,n.produce)(r,e=>{e.query=i}))}}}}}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_GreptimeDBTimeSeriesQuery.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_GreptimeDBTimeSeriesQuery.02b0ffbc.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_GreptimeDB_0_2_0_beta_3=self.chunk_GreptimeDB_0_2_0_beta_3||[]).push([["548"],{2192(e,t,r){var n=r(70451),i=Symbol.for("react.element"),l=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var n,l={},s=null,m=null;for(n in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(m=t.ref),t)a.call(t,n)&&!u.hasOwnProperty(n)&&(l[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===l[n]&&(l[n]=t[n]);return{$$typeof:i,type:e,key:s,ref:m,props:l,_owner:o.current}}t.Fragment=l,t.jsx=s,t.jsxs=s},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
|
|
3
3
|
SELECT
|
|
4
4
|
date_bin(INTERVAL '1 minute', ts) as ts,
|
|
5
5
|
avg(cpu_usage) as avg_cpu,
|
|
@@ -18,4 +18,4 @@ SELECT
|
|
|
18
18
|
FROM application_logs
|
|
19
19
|
WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
|
|
20
20
|
ORDER BY ts DESC
|
|
21
|
-
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),i=r(41865),l=r(56599),a=r(315),o=r(54227),u=r(29068);function s(e){let t=(0,l.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(a.A,{position:"relative",children:[(0,n.jsx)(o.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=l(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>a});var n=r(
|
|
21
|
+
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),i=r(41865),l=r(56599),a=r(315),o=r(54227),u=r(29068);function s(e){let t=(0,l.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(a.A,{position:"relative",children:[(0,n.jsx)(o.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=l(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>a});var n=r(23724);function i(e,t,r){let i,l,a,o,u,{start:s,end:m}=r,d=m.valueOf()-s.valueOf(),c={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:d.toString(),loading:!1},__range_s:{value:Math.floor(d/1e3).toString(),loading:!1},__range:{value:(l=Math.floor((i=Math.floor(d/1e3))/3600),a=Math.floor(i%3600/60),o=i%60,u="",l>0&&(u+=`${l}h`),a>0&&(u+=`${a}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...c,...t})}function l(e){return e?e.toLowerCase():null}function a(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=l(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=new Set(["greptime_timestamp","timestamp","ts","time"]);t=e.findIndex(e=>r.has(e.name.toLowerCase()))}return t}},85816(e,t,r){r.r(t),r.d(t,{GreptimeDBTimeSeriesQueryEditor:()=>g,getTimeSeriesData:()=>a,GreptimeDBTimeSeriesQuery:()=>_});var n=r(7140),i=r(57748);function l(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("int")||t.includes("float")||t.includes("double")||t.includes("decimal")||t.includes("number")}let a=async(e,t)=>{var r;if(!e.query)return{series:[]};let{start:a,end:o}=t.timeRange,u=(0,i.EY)(e.query,t.variableState,t.timeRange),s=await t.datasourceStore.getDatasourceClient(e.datasource??n.S),m=await s.query({start:a.getTime().toString(),end:o.getTime().toString(),query:u});if("error"===m.status)throw Error(m.error??"GreptimeDB query failed");let d=(0,i.qV)(m.data),c=(null==d||null==(r=d.schema)?void 0:r.column_schemas)??[],f=(null==d?void 0:d.rows)??[],p=function(e,t){var r,n,a,o;let u=(null==e||null==(r=e.schema)?void 0:r.column_schemas)??[],s=(null==e?void 0:e.rows)??[];if(!u.length||!s.length)return[];let m=(0,i.nu)(u);if(-1===m){let e=u.findIndex(e=>l(e.data_type));if(-1===e)return[];let r=(null==(a=u[e])?void 0:a.name)??"value",n=[];return(s.forEach((r,i)=>{let l=null==r?void 0:r[e],a="number"==typeof l?l:Number(l);Number.isFinite(a)&&n.push([t+i,a])}),0===n.length)?[]:[{name:r,labels:{},values:n}]}let d=u.findIndex((e,t)=>t!==m&&"greptime_value"===e.name.toLowerCase());-1===d&&(d=u.findIndex((e,t)=>t!==m&&"value"===e.name.toLowerCase())),-1===d&&(d=u.findIndex((e,t)=>t!==m&&l(e.data_type))),-1===d&&(d=u.findIndex((e,t)=>t!==m));let c=(null==(n=u[d])?void 0:n.name)??"value",f=new Map;for(let e of s){let t=(0,i.W0)(null==e?void 0:e[m],null==(o=u[m])?void 0:o.data_type);if(null===t)continue;let r=null==e?void 0:e[d],n="number"==typeof r?r:Number(r);if(!Number.isFinite(n))continue;let l={};u.forEach((t,r)=>{if(r===m||r===d)return;let n=null==e?void 0:e[r];l[t.name]=null==n?"":String(n)});let a=u.filter((e,t)=>t!==m&&t!==d).map(e=>`${e.name}=${l[e.name]??""}`).join("|"),s=`${c}|${a}`,p=f.get(s);p?p.values.push([t,n]):f.set(s,{name:function(e,t){let r=Object.entries(t);return 0===r.length?e:r.map(e=>{let[t,r]=e;return`${t}=${r}`}).join(",")}(c,l),labels:l,values:[[t,n]]})}return Array.from(f.values()).filter(e=>e.values.length>0)}(d,o.getTime()),g=function(e,t){let r=1/0;for(let t of e){let e=t.values.map(e=>{let[t]=e;return t}).toSorted((e,t)=>e-t);for(let t=1;t<e.length;t++){let n=e[t]-e[t-1];n>0&&n<r&&(r=n)}}return Number.isFinite(r)?r:t}(p,t.suggestedStepMs||3e4);return{series:p,timeRange:{start:a,end:o},stepMs:g,metadata:{executedQueryString:u,records:d,table:{columns:c,rows:f}}}};var o=r(23724),u=r(62540),s=r(315),m=r(38662),d=r(70451),c=r(71122),f=r(15062),p=r(64383);function g(e){let{onChange:t,value:r}=e,{datasource:i}=r,l=i??n.S,{query:a,handleQueryChange:g,handleQueryBlur:_}=(0,p.Z)(e),v=(0,d.useCallback)(e=>{g(e)},[g]);return(0,u.jsxs)(s.A,{spacing:1.5,children:[(0,u.jsx)(o.DatasourceSelect,{datasourcePluginKind:n.N,value:l,onChange:e=>{if(!(0,o.isVariableDatasource)(e)&&e.kind===n.N)return void t((0,m.produce)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,u.jsx)(c.M,{value:a,onChange:v,onBlur:_,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,m.produce)(r,e=>{e.query=a})))},placeholder:"Enter GreptimeDB SQL query"}),(0,u.jsxs)("details",{children:[(0,u.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:"#666",marginBottom:"8px"},children:"Query Examples"}),(0,u.jsx)("div",{style:{fontSize:"11px",color:"#777",backgroundColor:"#f5f5f5",padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"},children:f.t})]})]})}let _={getTimeSeriesData:a,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,o.parseVariables)(e.query))]})}},64383(e,t,r){r.d(t,{Z:()=>l});var n=r(38662),i=r(70451);function l(e){let{onChange:t,value:r}=e,[l,a]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(a(r.query||""),u(r.query)),{query:l,handleQueryChange:e=>{a(e)},handleQueryBlur:()=>{u(l),t((0,n.produce)(r,e=>{e.query=l}))}}}}}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_GreptimeDBTraceQuery.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_GreptimeDBTraceQuery.c403854b.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_GreptimeDB_0_2_0_beta_3=self.chunk_GreptimeDB_0_2_0_beta_3||[]).push([["361"],{2192(e,t,r){var n=r(70451),i=Symbol.for("react.element"),a=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,a={},l=null,m=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(m=t.ref),t)s.call(t,n)&&!u.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:i,type:e,key:l,ref:m,props:a,_owner:o.current}}t.Fragment=a,t.jsx=l,t.jsxs=l},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
|
|
3
3
|
SELECT
|
|
4
4
|
date_bin(INTERVAL '1 minute', ts) as ts,
|
|
5
5
|
avg(cpu_usage) as avg_cpu,
|
|
@@ -18,4 +18,4 @@ SELECT
|
|
|
18
18
|
FROM application_logs
|
|
19
19
|
WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
|
|
20
20
|
ORDER BY ts DESC
|
|
21
|
-
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>l});var n=r(62540),i=r(41865),a=r(56599),s=r(315),o=r(54227),u=r(29068);function l(e){let t=(0,a.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(s.A,{position:"relative",children:[(0,n.jsx)(o.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=a(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>s});var n=r(26659);function i(e,t,r){let i,a,s,o,u,{start:l,end:m}=r,c=m.valueOf()-l.valueOf(),d={__from:{value:l.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:c.toString(),loading:!1},__range_s:{value:Math.floor(c/1e3).toString(),loading:!1},__range:{value:(a=Math.floor((i=Math.floor(c/1e3))/3600),s=Math.floor(i%3600/60),o=i%60,u="",a>0&&(u+=`${a}h`),s>0&&(u+=`${s}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...d,...t})}function a(e){return e?e.toLowerCase():null}function s(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=a(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=new Set(["greptime_timestamp","timestamp","ts","time"]);t=e.findIndex(e=>r.has(e.name.toLowerCase()))}return t}},24388(e,t,r){r.r(t),r.d(t,{GreptimeDBTraceQuery:()=>T,toNanoString:()=>_,GreptimeDBTraceQueryEditor:()=>E,getGreptimeDBTraceData:()=>s});var n=r(26659),i=r(7140),a=r(57748);let s=async(e,t)=>{var r,s;let g=(0,n.replaceVariables)(e.query??"",t.variableState).trim();if(0===g.length)return{searchResult:[]};let v=function(e){if(e){if("string"==typeof e.name&&""===e.name.trim()){let{kind:t}=e;return t?{kind:t}:void 0}return e}}(e.datasource),S=await t.datasourceStore.getDatasourceClient(v??i.S),h=(null==(r=t.absoluteTimeRange)?void 0:r.start.getTime().toString())??"0",y=(null==(s=t.absoluteTimeRange)?void 0:s.end.getTime().toString())??"0",x=await S.query({query:g,start:h,end:y});if("error"===x.status)throw Error(x.error??"GreptimeDB trace query failed");let E=(0,a.qV)(x.data);return/where[\s\S]*trace_id\s*=/i.test(g)&&function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[];if(0===r.length)return!1;let n=o(r);return void 0!==n.trace_id&&void 0!==n.span_id}(E)?{trace:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{resourceSpans:[]};let i=o(r),a=r.filter(e=>e.name.startsWith("span_attributes.")),s=r.filter(e=>e.name.startsWith("resource_attributes.")),d=new Map;return n.forEach(e=>{let t=m(l(e,i,["trace_id","traceid","traceId"])),n=m(l(e,i,["span_id","spanid","spanId"]));if(!t||!n)return;let o=m(l(e,i,["parent_span_id","parentspanid","parentSpanId"])),g=m(l(e,i,["span_name","name","operation_name"]))??"(unknown span)",v=m(l(e,i,["span_kind","kind"]))??"SPAN_KIND_UNSPECIFIED",S=m(l(e,i,["service_name"]))??"unknown",h=m(l(e,i,["scope_name"]))??"",y=m(l(e,i,["scope_version"]))??"",x=i.timestamp??i.start_time??i.start_time_unix_nano,E=i.timestamp_end??i.end_time??i.end_time_unix_nano,T=i.duration_nano??i.duration_ns,N=void 0!==x?_(e[x],u(r,x))??"0":"0",b=(void 0!==E?_(e[E],u(r,E))??"0":void 0)??(void 0!==T?String(BigInt(N)+BigInt(_(e[T],u(r,T))??"0")):N),D=a.map(t=>{let r=i[t.name.toLowerCase()];if(void 0===r)return;let n=e[r];if(null!=n&&""!==n)return f(t.name.replace(/^span_attributes\./,""),n)}).filter(e=>void 0!==e),M=p(l(e,i,["span_events"])).map(e=>{let t=function(e){if(null==e)return;let t=c(e);if(void 0!==t)return String(BigInt(Math.trunc(t)));let r=new Date(String(e)).getTime();if(!Number.isNaN(r))return String(1000000n*BigInt(Math.trunc(r)))}(e.timeUnixNano??e.time_unix_nano)??N,r=m(e.name)??"event",n=e.attributes;return{timeUnixNano:t,name:r,attributes:n?Object.entries(n).map(e=>{let[t,r]=e;return f(t,r)}):[]}}),O=p(l(e,i,["span_links"])).map(e=>{let t=e.attributes,r=t?Object.entries(t).map(e=>{let[t,r]=e;return f(t,r)}):[];return{traceId:m(e.traceId??e.trace_id)??"",spanId:m(e.spanId??e.span_id)??"",attributes:r}}),w=m(l(e,i,["span_status_message"]))??"",C=function(e){let t=String(e??"").trim().toUpperCase();if(t)return"STATUS_CODE_OK"===t||"OK"===t||"1"===t?"STATUS_CODE_OK":"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t?"STATUS_CODE_ERROR":"STATUS_CODE_UNSET"}(l(e,i,["span_status_code","status_code"]));if(!d.has(S)){let t=[f("service.name",S)];s.forEach(r=>{let n=i[r.name.toLowerCase()];if(void 0===n)return;let a=e[n];null!=a&&""!==a&&t.push(f(r.name.replace(/^resource_attributes\./,""),a))}),d.set(S,{resourceAttrs:t,scopeSpans:new Map})}let R=d.get(S),B=`${h}|${y}`;R.scopeSpans.has(B)||R.scopeSpans.set(B,{scope:{name:h,version:y},spans:[]}),R.scopeSpans.get(B).spans.push({traceId:t,spanId:n,parentSpanId:o,name:g,kind:v,startTimeUnixNano:N,endTimeUnixNano:b,attributes:D,events:M,links:O,status:{message:w,code:C}})}),{resourceSpans:Array.from(d.entries()).map(e=>{let[t,r]=e;return{resource:{attributes:r.resourceAttrs},scopeSpans:Array.from(r.scopeSpans.values())}})}}(E),metadata:{executedQueryString:g}}:{searchResult:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return[];let i=o(r),s=new Map;return n.forEach(e=>{let t=m(l(e,i,["trace_id","traceid","traceId"]));if(!t)return;let n=function(e,t,r){for(let n of["timestamp","start_time","start_time_unix_nano","start_time_unix_ns","start_time_unix_ms","start_time_unix"]){let i=r[n];if(void 0===i||!t)continue;let s=(0,a.W0)(e[i],u(t,i));if(null!==s)return s}}(e,r,i),o=function(e,t,r){let n=c(l(e,r,["duration_ms"]));if(void 0!==n)return n;let i=c(l(e,r,["duration_nano","duration_ns"]));if(void 0!==i)return i/1e6;let s=r.timestamp??r.start_time??r.start_time_unix_nano,o=r.timestamp_end??r.end_time??r.end_time_unix_nano;if(t&&void 0!==s&&void 0!==o){let r=(0,a.W0)(e[s],u(t,s)),n=(0,a.W0)(e[o],u(t,o));if(null!==r&&null!==n)return Math.max(0,n-r)}return 0}(e,r,i),_=function(e,t,r){for(let n of["timestamp_end","end_time","end_time_unix_nano","end_time_unix_ns","end_time_unix_ms"]){let i=r[n];if(void 0===i||!t)continue;let s=(0,a.W0)(e[i],u(t,i));if(null!==s)return s}}(e,r,i)??(void 0!==n?n+o:void 0),p=m(l(e,i,["service_name","root_service_name"]))??"unknown",f=m(l(e,i,["span_name","root_trace_name","operation_name","name"]))??"(unknown span)",g=m(l(e,i,["parent_span_id","parentspanid","parentSpanId"])),v=s.get(t);v?(void 0!==n&&(v.startTimeUnixMs=0===v.startTimeUnixMs?n:Math.min(v.startTimeUnixMs,n)),void 0!==_&&(v.endTimeUnixMs=Math.max(v.endTimeUnixMs,_)),g||(v.rootTraceName=f,v.rootServiceName=p),v.serviceStats[p]||(v.serviceStats[p]={spanCount:0,errorCount:0}),v.serviceStats[p].spanCount+=1,d(l(e,i,["span_status_code","status_code"]))&&(v.serviceStats[p].errorCount+=1)):s.set(t,{traceId:t,startTimeUnixMs:n??0,endTimeUnixMs:_??n??0,rootServiceName:p,rootTraceName:f,serviceStats:{[p]:{spanCount:1,errorCount:+!!d(l(e,i,["span_status_code","status_code"]))}}})}),Array.from(s.values()).map(e=>({traceId:e.traceId,startTimeUnixMs:e.startTimeUnixMs,durationMs:Math.max(0,e.endTimeUnixMs-e.startTimeUnixMs),rootServiceName:e.rootServiceName,rootTraceName:e.rootTraceName,serviceStats:e.serviceStats})).toSorted((e,t)=>t.startTimeUnixMs-e.startTimeUnixMs)}(E),metadata:{executedQueryString:g}}};function o(e){let t={};return(e??[]).forEach((e,r)=>{t[e.name.toLowerCase()]=r}),t}function u(e,t){let r=e[t];if(!r)throw Error(`GreptimeDB SQL response missing column at index ${t}`);let n=r.data_type;if(!n)throw Error(`GreptimeDB SQL response missing data_type for column "${r.name}"`);return n}function l(e,t,r){for(let n of r){let r=t[n.toLowerCase()];if(void 0!==r)return e[r]}}function m(e){if(null!=e)return String(e)}function c(e){if(null==e)return;if("number"==typeof e)return Number.isFinite(e)?e:void 0;let t=Number(e);return Number.isFinite(t)?t:void 0}function d(e){let t=String(e??"").trim().toUpperCase();return"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t}function _(e,t){let r;if(null==e)return;let n=c(e);if(void 0===n)return;let i=t.toLowerCase();if(i.includes("nanosecond"))return String(BigInt(Math.trunc(n)));if(i.includes("microsecond"))return String(1000n*BigInt(Math.trunc(n)));if(i.includes("millisecond"))return String(1000000n*BigInt(Math.trunc(n)));if(i.includes("second"))return String(1000000000n*BigInt(Math.trunc(n)));if((r=t.toLowerCase()).includes("int")||r.includes("uint")||"bigint"===r)return String(BigInt(Math.trunc(n)));throw Error(`Unsupported GreptimeDB data_type: ${t}`)}function p(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{}return[]}function f(e,t){return{key:e,value:{stringValue:"string"==typeof t?t:JSON.stringify(t)}}}var g=r(62540),v=r(315),S=r(38662),h=r(70451),y=r(71122),x=r(64383);function E(e){let{onChange:t,value:r}=e,{datasource:a}=r,s=a??i.S,{query:o,handleQueryChange:u,handleQueryBlur:l}=(0,x.Z)(e),m=(0,h.useCallback)(e=>{u(e)},[u]);return(0,g.jsxs)(v.A,{spacing:1.5,children:[(0,g.jsx)(n.DatasourceSelect,{datasourcePluginKind:i.N,value:s,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===i.N)return void t((0,S.produce)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,g.jsx)(y.M,{value:o,onChange:m,onBlur:l,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,S.produce)(r,e=>{e.query=o})))},placeholder:"Enter SQL for trace search or trace details"})]})}let T={getTraceData:s,OptionsEditorComponent:E,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,n.parseVariables)(e.query))]})}},64383(e,t,r){r.d(t,{Z:()=>a});var n=r(38662),i=r(70451);function a(e){let{onChange:t,value:r}=e,[a,s]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(s(r.query||""),u(r.query)),{query:a,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{u(a),t((0,n.produce)(r,e=>{e.query=a}))}}}}}]);
|
|
21
|
+
LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>l});var n=r(62540),i=r(41865),a=r(56599),s=r(315),o=r(54227),u=r(29068);function l(e){let t=(0,a.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(s.A,{position:"relative",children:[(0,n.jsx)(o.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(u.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=a(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>s});var n=r(23724);function i(e,t,r){let i,a,s,o,u,{start:l,end:m}=r,c=m.valueOf()-l.valueOf(),d={__from:{value:l.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:c.toString(),loading:!1},__range_s:{value:Math.floor(c/1e3).toString(),loading:!1},__range:{value:(a=Math.floor((i=Math.floor(c/1e3))/3600),s=Math.floor(i%3600/60),o=i%60,u="",a>0&&(u+=`${a}h`),s>0&&(u+=`${s}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...d,...t})}function a(e){return e?e.toLowerCase():null}function s(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=a(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=new Set(["greptime_timestamp","timestamp","ts","time"]);t=e.findIndex(e=>r.has(e.name.toLowerCase()))}return t}},24388(e,t,r){r.r(t),r.d(t,{GreptimeDBTraceQuery:()=>T,toNanoString:()=>_,GreptimeDBTraceQueryEditor:()=>E,getGreptimeDBTraceData:()=>s});var n=r(23724),i=r(7140),a=r(57748);let s=async(e,t)=>{var r,s;let g=(0,n.replaceVariables)(e.query??"",t.variableState).trim();if(0===g.length)return{searchResult:[]};let v=function(e){if(e){if("string"==typeof e.name&&""===e.name.trim()){let{kind:t}=e;return t?{kind:t}:void 0}return e}}(e.datasource),S=await t.datasourceStore.getDatasourceClient(v??i.S),h=(null==(r=t.absoluteTimeRange)?void 0:r.start.getTime().toString())??"0",y=(null==(s=t.absoluteTimeRange)?void 0:s.end.getTime().toString())??"0",x=await S.query({query:g,start:h,end:y});if("error"===x.status)throw Error(x.error??"GreptimeDB trace query failed");let E=(0,a.qV)(x.data);return/where[\s\S]*trace_id\s*=/i.test(g)&&function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[];if(0===r.length)return!1;let n=o(r);return void 0!==n.trace_id&&void 0!==n.span_id}(E)?{trace:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{resourceSpans:[]};let i=o(r),a=r.filter(e=>e.name.startsWith("span_attributes.")),s=r.filter(e=>e.name.startsWith("resource_attributes.")),d=new Map;return n.forEach(e=>{let t=m(l(e,i,["trace_id","traceid","traceId"])),n=m(l(e,i,["span_id","spanid","spanId"]));if(!t||!n)return;let o=m(l(e,i,["parent_span_id","parentspanid","parentSpanId"])),g=m(l(e,i,["span_name","name","operation_name"]))??"(unknown span)",v=m(l(e,i,["span_kind","kind"]))??"SPAN_KIND_UNSPECIFIED",S=m(l(e,i,["service_name"]))??"unknown",h=m(l(e,i,["scope_name"]))??"",y=m(l(e,i,["scope_version"]))??"",x=i.timestamp??i.start_time??i.start_time_unix_nano,E=i.timestamp_end??i.end_time??i.end_time_unix_nano,T=i.duration_nano??i.duration_ns,N=void 0!==x?_(e[x],u(r,x))??"0":"0",b=(void 0!==E?_(e[E],u(r,E))??"0":void 0)??(void 0!==T?String(BigInt(N)+BigInt(_(e[T],u(r,T))??"0")):N),D=a.map(t=>{let r=i[t.name.toLowerCase()];if(void 0===r)return;let n=e[r];if(null!=n&&""!==n)return f(t.name.replace(/^span_attributes\./,""),n)}).filter(e=>void 0!==e),M=p(l(e,i,["span_events"])).map(e=>{let t=function(e){if(null==e)return;let t=c(e);if(void 0!==t)return String(BigInt(Math.trunc(t)));let r=new Date(String(e)).getTime();if(!Number.isNaN(r))return String(1000000n*BigInt(Math.trunc(r)))}(e.timeUnixNano??e.time_unix_nano)??N,r=m(e.name)??"event",n=e.attributes;return{timeUnixNano:t,name:r,attributes:n?Object.entries(n).map(e=>{let[t,r]=e;return f(t,r)}):[]}}),O=p(l(e,i,["span_links"])).map(e=>{let t=e.attributes,r=t?Object.entries(t).map(e=>{let[t,r]=e;return f(t,r)}):[];return{traceId:m(e.traceId??e.trace_id)??"",spanId:m(e.spanId??e.span_id)??"",attributes:r}}),w=m(l(e,i,["span_status_message"]))??"",C=function(e){let t=String(e??"").trim().toUpperCase();if(t)return"STATUS_CODE_OK"===t||"OK"===t||"1"===t?"STATUS_CODE_OK":"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t?"STATUS_CODE_ERROR":"STATUS_CODE_UNSET"}(l(e,i,["span_status_code","status_code"]));if(!d.has(S)){let t=[f("service.name",S)];s.forEach(r=>{let n=i[r.name.toLowerCase()];if(void 0===n)return;let a=e[n];null!=a&&""!==a&&t.push(f(r.name.replace(/^resource_attributes\./,""),a))}),d.set(S,{resourceAttrs:t,scopeSpans:new Map})}let R=d.get(S),B=`${h}|${y}`;R.scopeSpans.has(B)||R.scopeSpans.set(B,{scope:{name:h,version:y},spans:[]}),R.scopeSpans.get(B).spans.push({traceId:t,spanId:n,parentSpanId:o,name:g,kind:v,startTimeUnixNano:N,endTimeUnixNano:b,attributes:D,events:M,links:O,status:{message:w,code:C}})}),{resourceSpans:Array.from(d.entries()).map(e=>{let[t,r]=e;return{resource:{attributes:r.resourceAttrs},scopeSpans:Array.from(r.scopeSpans.values())}})}}(E),metadata:{executedQueryString:g}}:{searchResult:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return[];let i=o(r),s=new Map;return n.forEach(e=>{let t=m(l(e,i,["trace_id","traceid","traceId"]));if(!t)return;let n=function(e,t,r){for(let n of["timestamp","start_time","start_time_unix_nano","start_time_unix_ns","start_time_unix_ms","start_time_unix"]){let i=r[n];if(void 0===i||!t)continue;let s=(0,a.W0)(e[i],u(t,i));if(null!==s)return s}}(e,r,i),o=function(e,t,r){let n=c(l(e,r,["duration_ms"]));if(void 0!==n)return n;let i=c(l(e,r,["duration_nano","duration_ns"]));if(void 0!==i)return i/1e6;let s=r.timestamp??r.start_time??r.start_time_unix_nano,o=r.timestamp_end??r.end_time??r.end_time_unix_nano;if(t&&void 0!==s&&void 0!==o){let r=(0,a.W0)(e[s],u(t,s)),n=(0,a.W0)(e[o],u(t,o));if(null!==r&&null!==n)return Math.max(0,n-r)}return 0}(e,r,i),_=function(e,t,r){for(let n of["timestamp_end","end_time","end_time_unix_nano","end_time_unix_ns","end_time_unix_ms"]){let i=r[n];if(void 0===i||!t)continue;let s=(0,a.W0)(e[i],u(t,i));if(null!==s)return s}}(e,r,i)??(void 0!==n?n+o:void 0),p=m(l(e,i,["service_name","root_service_name"]))??"unknown",f=m(l(e,i,["span_name","root_trace_name","operation_name","name"]))??"(unknown span)",g=m(l(e,i,["parent_span_id","parentspanid","parentSpanId"])),v=s.get(t);v?(void 0!==n&&(v.startTimeUnixMs=0===v.startTimeUnixMs?n:Math.min(v.startTimeUnixMs,n)),void 0!==_&&(v.endTimeUnixMs=Math.max(v.endTimeUnixMs,_)),g||(v.rootTraceName=f,v.rootServiceName=p),v.serviceStats[p]||(v.serviceStats[p]={spanCount:0,errorCount:0}),v.serviceStats[p].spanCount+=1,d(l(e,i,["span_status_code","status_code"]))&&(v.serviceStats[p].errorCount+=1)):s.set(t,{traceId:t,startTimeUnixMs:n??0,endTimeUnixMs:_??n??0,rootServiceName:p,rootTraceName:f,serviceStats:{[p]:{spanCount:1,errorCount:+!!d(l(e,i,["span_status_code","status_code"]))}}})}),Array.from(s.values()).map(e=>({traceId:e.traceId,startTimeUnixMs:e.startTimeUnixMs,durationMs:Math.max(0,e.endTimeUnixMs-e.startTimeUnixMs),rootServiceName:e.rootServiceName,rootTraceName:e.rootTraceName,serviceStats:e.serviceStats})).toSorted((e,t)=>t.startTimeUnixMs-e.startTimeUnixMs)}(E),metadata:{executedQueryString:g}}};function o(e){let t={};return(e??[]).forEach((e,r)=>{t[e.name.toLowerCase()]=r}),t}function u(e,t){let r=e[t];if(!r)throw Error(`GreptimeDB SQL response missing column at index ${t}`);let n=r.data_type;if(!n)throw Error(`GreptimeDB SQL response missing data_type for column "${r.name}"`);return n}function l(e,t,r){for(let n of r){let r=t[n.toLowerCase()];if(void 0!==r)return e[r]}}function m(e){if(null!=e)return String(e)}function c(e){if(null==e)return;if("number"==typeof e)return Number.isFinite(e)?e:void 0;let t=Number(e);return Number.isFinite(t)?t:void 0}function d(e){let t=String(e??"").trim().toUpperCase();return"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t}function _(e,t){let r;if(null==e)return;let n=c(e);if(void 0===n)return;let i=t.toLowerCase();if(i.includes("nanosecond"))return String(BigInt(Math.trunc(n)));if(i.includes("microsecond"))return String(1000n*BigInt(Math.trunc(n)));if(i.includes("millisecond"))return String(1000000n*BigInt(Math.trunc(n)));if(i.includes("second"))return String(1000000000n*BigInt(Math.trunc(n)));if((r=t.toLowerCase()).includes("int")||r.includes("uint")||"bigint"===r)return String(BigInt(Math.trunc(n)));throw Error(`Unsupported GreptimeDB data_type: ${t}`)}function p(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{}return[]}function f(e,t){return{key:e,value:{stringValue:"string"==typeof t?t:JSON.stringify(t)}}}var g=r(62540),v=r(315),S=r(38662),h=r(70451),y=r(71122),x=r(64383);function E(e){let{onChange:t,value:r}=e,{datasource:a}=r,s=a??i.S,{query:o,handleQueryChange:u,handleQueryBlur:l}=(0,x.Z)(e),m=(0,h.useCallback)(e=>{u(e)},[u]);return(0,g.jsxs)(v.A,{spacing:1.5,children:[(0,g.jsx)(n.DatasourceSelect,{datasourcePluginKind:i.N,value:s,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===i.N)return void t((0,S.produce)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,g.jsx)(y.M,{value:o,onChange:m,onBlur:l,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,S.produce)(r,e=>{e.query=o})))},placeholder:"Enter SQL for trace search or trace details"})]})}let T={getTraceData:s,OptionsEditorComponent:E,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,n.parseVariables)(e.query))]})}},64383(e,t,r){r.d(t,{Z:()=>a});var n=r(38662),i=r(70451);function a(e){let{onChange:t,value:r}=e,[a,s]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(s(r.query||""),u(r.query)),{query:a,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{u(a),t((0,n.produce)(r,e=>{e.query=a}))}}}}}]);
|