frameErrors=append(frameErrors,errors.Wrapf(err,"Path match failed for pattern %s with path %s",pathPattern,path))
returndata.HierarchicalFrame{},frameErrors
}
// we allow a single level to be examined or we never get going
if!match&¤tDepth>1{
returndata.HierarchicalFrame{},frameErrors
}
frame,err:=zkc.resourceManager.DbClient.ExecuteStatement(path,fmt.Sprintf("SELECT name FROM system.zookeeper WHERE path='%s' LIMIT %d",path,rowLimit))
iferr!=nil{
frameErrors=append(frameErrors,errors.Wrapf(err,"Unable to read zookeeper table path for sub paths %s",path))
returndata.HierarchicalFrame{},frameErrors
}
// this isn't ideal, we add re-execute the query to our collection as this will be consumed by the output lazily
outputFrame,err:=zkc.resourceManager.DbClient.ExecuteStatement(path,fmt.Sprintf("SELECT * FROM system.zookeeper WHERE path='%s' LIMIT %d",path,rowLimit))
iferr!=nil{
frameErrors=append(frameErrors,errors.Wrapf(err,"Unable to read zookeeper table path %s",path))
returndata.HierarchicalFrame{},frameErrors
}
frameComponents:=strings.Split(path,"/")
frameId:=frameComponents[len(frameComponents)-1]
for{
values,ok,err:=frame.Next()
iferr!=nil{
frameErrors=append(frameErrors,errors.Wrapf(err,"unable to read frame %s",frame.Name()))
Param:config.NewParam("path_pattern","Glob pattern for zookeeper path matching. Change with caution.",false),
},
config.IntParam{
Value:8,
Param:config.NewParam("max_depth","Max depth for zookeeper navigation.",false),
},
config.IntParam{
Value:10,
Param:config.NewParam("row_limit","Maximum number of rows/sub nodes to collect/expand from any zookeeper leaf. Negative values mean unlimited.",false),
},
},
}
}
func(zkc*ZookeeperCollector)IsDefault()bool{
returnfalse
}
func(zkc*ZookeeperCollector)Description()string{
return"Collects Zookeeper information available within ClickHouse."