api-docs
application文件
该文件是一些基本配置,端口、日志等,核心的就是metadata-config参数了。
例子:
metadata-config:
hosts: your es metadata cluster hosts
headers:
Authorization: 'username password'
建表详解
建表说明
建表语句中的字段,时间字段是必需,如表中的@timestamp字段,作为在kibana创建index pattern时的时间选项,其它字段根据本身业务查询条件按需添加。
匹配时间字段的逻辑如下,满足其一即可:
1)字段为Date类型,比如DateTime64类型,会被认为是时间类型
2)或者字段名中包含time,比如(@timestamp UInt64),会被认为是时间类型
下面是一个建表语句的例子
create database ckibana;
use ckibana;
CREATE TABLE ckibana.table_local
(
`request_method` LowCardinality(String),
`request_time` Float64,
`http_host` String,
`@timestamp` UInt64,
`ck_assembly_extension` String,
INDEX timestamp_index `@timestamp` TYPE minmax GRANULARITY 8192
)
ENGINE = MergeTree
PARTITION BY (toYYYYMMDD(toDateTime(`@timestamp` / 1000, 'Asia/Shanghai')), toHour(toDateTime(`@timestamp` / 1000, 'Asia/Shanghai')))
ORDER BY (`http_host`)
SETTINGS in_memory_parts_enable_wal = 0, index_granularity = 8192;
CREATE TABLE IF NOT EXISTS ckibana.table_all AS ckibana.table_local ENGINE Distributed('clickhouse_cluster', ckibana, table_local, rand());
当要使用采样功能时,需要在建表语句中修改ORDER BY、SAMPLE BY语句,更详细可以参考clickhouse官方说明 。
说明:采样字段可以是自己定义的字段,推荐还是使用@timestamp字段作为采样字段,不用额外创建字段
create database ckibana;
use ckibana;
CREATE TABLE ckibana.table_local
(
`request_method` LowCardinality(String),
`request_time` Float64,
`http_host` String,
`@timestamp` UInt64,
`ck_assembly_extension` String,
INDEX timestamp_index `@timestamp` TYPE minmax GRANULARITY 8192
)
ENGINE = MergeTree
PARTITION BY (toYYYYMMDD(toDateTime(`@timestamp` / 1000, 'Asia/Shanghai')), toHour(toDateTime(`@timestamp` / 1000, 'Asia/Shanghai')))
ORDER BY (`http_host`, intHash64(`@timestamp`))
SAMPLE BY intHash64(`@timestamp`)
SETTINGS in_memory_parts_enable_wal = 0, index_granularity = 8192;
CREATE TABLE IF NOT EXISTS ckibana.table_all AS ckibana.table_local ENGINE Distributed('clickhouse_cluster', ckibana, table_local, rand());
es的类型 跟 ck的类型的mapping
相关系统索引
proxy-settings
默认该索引名为proxy-settings,如您使用一个元数据集群来管理多个kibana proxy,可以利用application.yml的metadata.config.tingsSuffix属性。
参数详解
更新ES元数据集群配置,ckibana提供如下接口
1)更新CK配置,不会立即生效,需要等一次任务执行时间10s
curl --location --request POST 'localhost:8080/config/updateCk?url=ip:Port&user=yourUserName&pass=yourPass&defaultCkDatabase=yourCkDatabaseName'
2)更新ES配置,不会立即生效,需要等一次任务执行时间10s
curl --location --request POST 'localhost:8080/config/updateEs?host=esHost&headers=key:value,key2:value2'
3)更新白名单索引
curl --location --request POST 'localhost:8080/config/updateWhiteIndexList?list=index1,index2'
4)更新黑名单索引
curl --location --request POST 'localhost:8080/config/updateBlackIndexList?list=index1,index2'
5)更新采样索引
curl --location --request POST 'localhost:8080/config/updateSampleIndexList?list=index1,index2'
6)更新sampleCountMaxThreshold
curl --location --request POST 'localhost:8080/config/updateSampleCountMaxThreshold?sampleCountMaxThreshold=1500000'
7)更新useCache
curl --location --request POST 'localhost:8080/config/updateUseCache?useCache=true'
8)更新maxResultRow
curl --location --request POST 'localhost:8080/config/updateMaxResultRow?maxResultRow=40000'
9)更新roundAbleMinPeriod
curl --location --request POST 'localhost:8080/config/updateRoundAbleMinPeriod?roundAbleMinPeriod=120000'
10)更新round
curl --location --request POST 'localhost:8080/config/updateRound?round=10'
11)更新maxTimeRange
curl --location --request POST 'localhost:8080/config/updateMaxTimeRange?maxTimeRange=864000000'
12)更新enableMonitoring
curl --location --request POST 'localhost:8080/config/updateEnableMonitoring?enableMonitoring=false'
13)更新msearchThreadPoolCoreSize
curl --location --request POST 'localhost:8080/config/updateMsearchThreadPoolCoreSize?msearchThreadPoolCoreSize=4'
14)获取配置接口
curl --location 'localhost:8080/config/all'
15)全量更新配置接口
curl --location 'localhost:8080/config/all' \
--header 'Content-Type: application/json' \
--data '{
"query":{
"sampleIndexPatterns":[
"index1",
"index2"
],
"sampleCountMaxThreshold":"1500000",
"useCache":false
},
"proxy":{
"roundAbleMinPeriod":120000,
"maxTimeRange":86400000,
"enableMonitoring":true,
"blackIndexList":[
"index1",
"index2"
],
"whiteIndexList":[
"index1",
"index2"
],
"es":{
"host":"esHost
"headers":[
{
"Authorization":"yourEsClusterAuthorization"
}
]
},
"ck":{
"url":"ip:Port",
"user":"yourUserName",
"pass":"yourPass",
"defaultCkDatabase":"yourCkDatabaseName"
}
}
}'
proxy-monitor
提供监控索引。可以通过配置打开。
可利用该索引进行kibana上的sql监控。
proxy-black-list
索引查询sql黑名单。可以通过配置打开。
该索引可以通过kibana proxy直接操作:
获取
curl --location 'http://localhost:8080/proxy/_black_list'
新增
range: 查询间隔(毫秒)
sql: 去除时间范围的条件查询语句,可在monitor日志中获取到
curl --location 'http://localhost:8080/proxy/_black_list' \
--header 'Content-Type: application/json' \
--data-raw '{
"range": "900000",
"sql": "((`@timestamp` = 1698293120000))"
}'
删除
curl --location --request DELETE 'http://localhost:8080/proxy/_black_list/{id}'