refactor: rename instance_query to instant_query

This commit is contained in:
ning1875 2021-07-19 19:17:22 +08:00 committed by GitHub
parent 407f9ca6ad
commit 034b7a642e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 16 deletions

View File

@ -20,7 +20,7 @@ type DataSource interface {
PushEndpoint
QueryData(inputs vos.DataQueryParam) []*vos.DataQueryResp // 查询一段时间
QueryDataInstance(ql string) []*vos.DataQueryInstanceResp // 查询一个时间点数据 等同于prometheus instance_query
QueryDataInstant(ql string) []*vos.DataQueryInstanceResp // 查询一个时间点数据 等同于prometheus instant_query
QueryTagKeys(recv vos.CommonTagQueryParam) *vos.TagKeyQueryResp // 获取标签的names
QueryTagValues(recv vos.CommonTagQueryParam) *vos.TagValueQueryResp // 根据一个label_name获取 values
QueryTagPairs(recv vos.CommonTagQueryParam) *vos.TagPairQueryResp // 根据匹配拿到所有 series 上面三个使用统一的结构体

View File

@ -616,7 +616,7 @@ func (pd *PromeDataSource) QueryTagPairs(recv vos.CommonTagQueryParam) *vos.TagP
return respD
}
func (pd *PromeDataSource) QueryDataInstance(ql string) []*vos.DataQueryInstanceResp {
func (pd *PromeDataSource) QueryDataInstant(ql string) []*vos.DataQueryInstanceResp {
respD := make([]*vos.DataQueryInstanceResp, 0)
pv := pd.QueryVector(ql)
if pv == nil {

View File

@ -42,10 +42,12 @@ func configRoutes(r *gin.Engine) {
// 开源版本,为了支持图表分享功能,允许匿名查询数据
guest.POST("/query", GetData)
guest.POST("/instant-query", GetDataInstant)
guest.POST("/tag-pairs", GetTagPairs)
guest.POST("/tag-keys", GetTagKeys)
guest.POST("/tag-values", GetTagValues)
guest.POST("/tag-metrics", GetMetrics)
guest.GET("/check-promql", checkPromeQl)
}
// for brower, expose location in nginx.conf
@ -170,13 +172,6 @@ func configRoutes(r *gin.Engine) {
pages.GET("/status", Status)
pages.POST("/query", GetData)
pages.POST("/query_instance", GetDataInstance)
pages.POST("/tag-keys", GetTagKeys)
pages.POST("/tag-values", GetTagValues)
pages.POST("/tag-metrics", GetMetrics)
pages.POST("/tag-pairs", GetTagPairs)
}
// for thirdparty, do not expose location in nginx.conf
@ -296,13 +291,12 @@ func configRoutes(r *gin.Engine) {
v1.GET("/status", Status)
v1.POST("/query", GetData)
v1.POST("/query_instance", GetDataInstance)
v1.GET("/check-promql", checkPromeQl)
v1.POST("/instant-query", GetDataInstant)
v1.POST("/tag-keys", GetTagKeys)
v1.POST("/tag-values", GetTagValues)
v1.POST("/tag-metrics", GetMetrics)
v1.POST("/tag-pairs", GetTagPairs)
v1.GET("/check-promql", checkPromeQl)
}
push := r.Group("/v1/n9e/series").Use(gzip.Gzip(gzip.DefaultCompression))

View File

@ -206,7 +206,7 @@ func GetData(c *gin.Context) {
renderData(c, resp, nil)
}
func GetDataInstance(c *gin.Context) {
func GetDataInstant(c *gin.Context) {
dataSource, err := backend.GetDataSourceFor("")
if err != nil {
logger.Warningf("could not find datasource")
@ -214,8 +214,8 @@ func GetDataInstance(c *gin.Context) {
return
}
var input vos.DataQueryInstanceParam
var input vos.DataQueryInstantParam
dangerous(c.ShouldBindJSON(&input))
resp := dataSource.QueryDataInstance(input.PromeQl)
resp := dataSource.QueryDataInstant(input.PromeQl)
renderData(c, resp, nil)
}

View File

@ -33,7 +33,7 @@ type DataQueryParam struct {
End int64 `json:"end"`
}
type DataQueryInstanceParam struct {
type DataQueryInstantParam struct {
PromeQl string `json:"prome_ql"`
}