title |
---|
Playground新功能 |
:::info 普通信息 支持自定义标题 :::
::: tip 提示信息框 使用方法同上 :::
:::danger 警告信息 使用方法同上 :::
:::warning 注意信息 这篇文章需要在头部加入title配置,否则无法正确显示目录 :::
:::details 折叠信息 这一部分内容是被折叠的 :::
::: code-group
auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", *username, *password)))
exporter, err := otlpmetrichttp.New(
context.Background(),
otlpmetrichttp.WithEndpoint(*dbHost),
otlpmetrichttp.WithURLPath("/v1/otlp/v1/metrics"),
otlpmetrichttp.WithHeaders(map[string]string{
"X-Greptime-DB-Name": *dbName,
"Authorization": "Basic " + auth,
}),
otlpmetrichttp.WithTimeout(time.Second*5),
)
import SqlOperation from './operation'
import { SqlState, SqlInsertValuesState, SqlConfigState, InsertQueueConfigState } from '../type/sql'
import axios from 'axios'
const qs = require('qs')
class Sql extends SqlOperation {
url: string
sql: SqlState
insertQueueConfig: InsertQueueConfigState
insertValues: Map<string, SqlInsertValuesState>
timeoutId: Map<string, ReturnType<typeof setTimeout>>
constructor(dbname: string, sqlConfig: SqlConfigState) {
super()
this.sql = {} as SqlState
this.insertQueueConfig = sqlConfig.insertQueueConfig
this.insertValues = new Map()
this.timeoutId = new Map()
this.url = `/v1/sql?db=${dbname}`
}
runSQL = async function (sql) {
let res: any = await axios.post(
this.url,
qs.stringify({
sql,
})
)
return await res
}
}
export default Sql
String endpoint = String.format("https://%s/v1/otlp/v1/metrics", dbHost);
String auth = username + ":" + password;
String b64Auth = new String(Base64.getEncoder().encode(auth.getBytes()));
OtlpHttpMetricExporter exporter = OtlpHttpMetricExporter.builder()
.setEndpoint(endpoint)
.addHeader("X-Greptime-DB-Name", db)
.addHeader("Authorization", String.format("Basic %s", b64Auth))
.setTimeout(Duration.ofSeconds(5))
.build();
auth = f"{username}:{password}"
b64_auth = base64.b64encode(auth.encode()).decode("ascii")
endpoint = f"https://{host}/v1/otlp/v1/metrics"
exporter = OTLPMetricExporter(
endpoint=endpoint,
headers={"Authorization": f"Basic {b64_auth}", "X-Greptime-DB-Name": db},
timeout=5)
:::
打开https://greptime.com/playground?gistId={your_gist_id}
,就可以加载自定义的内容了。
测试环境可用:https://89dd1e92.greptime-website.pages.dev/playground?gistId={your_gist_id}
例子:
SELECT * FROM cpu_metrics ORDER BY ts DESC;
-- sql (line|usage_user|hostname,environment)
SELECT * FROM cpu_metrics ORDER BY ts DESC;
sql
代码块会自动转换为可执行代码块。
bilibili_video_list_info_new{bvid=~'BV1a',__field__='view'}
PromQL
代码块会自动转换为可执行代码块。