-
Notifications
You must be signed in to change notification settings - Fork 26
feat: log query and log pipelines #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
58b53d2
feat: logs
sunchanglong 04517b5
fix: interceptor
sunchanglong c1e3b8a
build: update pnpm lockfile
sunchanglong 84ab4a7
fix: table selection
sunchanglong 0ab48e0
fix: columns visible
sunchanglong 7e1cd4a
fix: langjson
sunchanglong 49e44d2
build: update pnpm lockfile
sunchanglong 438d34c
feat: reorder menu
sunchanglong 7db95fc
fix: typo
sunchanglong be93452
fix: pipeline db
sunchanglong 2388d85
fix: add db init
sunchanglong 1696b02
feat: uppercase
sunchanglong 10f509a
fix: export name
sunchanglong 696df77
fix: typo
sunchanglong 07599e5
feat: tsconfig
sunchanglong ada3f58
fix: ts
sunchanglong cd54b5e
feat: select auto widh
sunchanglong 094182b
refactor: remove scripts module
ZonaHex e20a715
Merge branch 'main' into feat/logs
sunchanglong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import axios from 'axios' | ||
import qs from 'qs' | ||
import dayjs from 'dayjs' | ||
import editorAPI from './editor' | ||
|
||
const { runSQL } = editorAPI | ||
const url = '/v1/events/pipelines' | ||
const sqlUrl = `/v1/sql` | ||
|
||
const makeSqlData = (sql: string) => { | ||
return qs.stringify({ | ||
sql, | ||
}) | ||
} | ||
|
||
export type PipeFile = { | ||
name: string | ||
content?: string | ||
version: string | ||
} | ||
|
||
/* eslint-disable */ | ||
function nanoTimestampToUTCString(nanoTimestamp: bigint) { | ||
nanoTimestamp = BigInt(nanoTimestamp) | ||
const divide1 = BigInt(1000000000) | ||
const seconds = nanoTimestamp / divide1 // 纳秒转秒 | ||
const divide2 = BigInt(1000000) | ||
const milliseconds = Number((nanoTimestamp % divide1) / divide2) // 毫秒部分 | ||
const nanoseconds = Number(nanoTimestamp % divide2) // 纳秒部分 | ||
|
||
// 使用 Date 对象将秒转换为 UTC | ||
const date = new Date(Number(seconds) * 1000) | ||
const isoString = date.toISOString().replace('Z', '').replace('.000', '') | ||
// 拼接毫秒和纳秒部分 | ||
return `${isoString}.${String(milliseconds).padStart(3, '0')}${String(nanoseconds).padStart(6, '0')}Z` | ||
} | ||
|
||
/* eslint-enable */ | ||
export function create(pipeFile: PipeFile) { | ||
const { content, name } = pipeFile | ||
const file = new File([content], `${name}.yaml`, { | ||
type: 'application/yaml', | ||
}) | ||
const formData = new FormData() | ||
formData.append('file', file) | ||
return axios.postForm(`${url}/${name}`, formData) | ||
} | ||
|
||
export function list() { | ||
return runSQL( | ||
`SELECT name,max(created_at) as created_at FROM greptime_private.pipelines group by name order by created_at desc` | ||
).then((result) => { | ||
return result.output[0].records.rows.map((row: any) => { | ||
return { | ||
name: row[0], | ||
version: nanoTimestampToUTCString(row[1]), | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
export function getByName(name: string): Promise<PipeFile> { | ||
const sql = `select name, created_at, pipeline | ||
from greptime_private.pipelines | ||
where name = '${name}' | ||
order by created_at desc | ||
limit 1` | ||
return runSQL(sql).then((result) => { | ||
const row = result.output[0].records.rows[0] as any | ||
return { | ||
name: row[0], | ||
version: nanoTimestampToUTCString(row[1]), | ||
content: row[2], | ||
} | ||
}) | ||
} | ||
|
||
export function del(name: string, version: string) { | ||
return axios.delete(`${url}/${name}`, { | ||
params: { | ||
version, | ||
}, | ||
}) | ||
} | ||
|
||
export function debug(name: string, content: any) { | ||
return axios.post(`${url}/dryrun?pipeline_name=${name}`, JSON.parse(content), { | ||
headers: { | ||
'Content-Type': 'application/json', // Set Content-Type | ||
}, | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.