Refine log messages
This commit is contained in:
@@ -80,7 +80,7 @@ func (ds *ZabbixDatasource) CheckHealth(ctx context.Context, req *backend.CheckH
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
res.Status = backend.HealthStatusError
|
res.Status = backend.HealthStatusError
|
||||||
res.Message = err.Error()
|
res.Message = err.Error()
|
||||||
ds.logger.Error("Error connecting zabbix", "err", err)
|
ds.logger.Error("Error connecting Zabbix server", "err", err)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (ds *ZabbixDatasourceInstance) ZabbixQuery(ctx context.Context, apiReq *Zab
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := CachedMethods[apiReq.Method]; ok {
|
if _, ok := CachedMethods[apiReq.Method]; ok {
|
||||||
ds.logger.Debug("Write result to cache", "method", apiReq.Method)
|
ds.logger.Debug("Writing result to cache", "method", apiReq.Method)
|
||||||
ds.queryCache.SetAPIRequest(apiReq, resultJson)
|
ds.queryCache.SetAPIRequest(apiReq, resultJson)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -80,14 +80,12 @@ func (ds *ZabbixDatasourceInstance) TestConnection(ctx context.Context) (string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultByte, _ := response.MarshalJSON()
|
resultByte, _ := response.MarshalJSON()
|
||||||
ds.logger.Debug("TestConnection", "result", string(resultByte))
|
|
||||||
|
|
||||||
return string(resultByte), nil
|
return string(resultByte), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZabbixRequest checks authentication and makes a request to the Zabbix API
|
// ZabbixRequest checks authentication and makes a request to the Zabbix API
|
||||||
func (ds *ZabbixDatasourceInstance) ZabbixRequest(ctx context.Context, method string, params ZabbixAPIParams) (*simplejson.Json, error) {
|
func (ds *ZabbixDatasourceInstance) ZabbixRequest(ctx context.Context, method string, params ZabbixAPIParams) (*simplejson.Json, error) {
|
||||||
ds.logger.Debug("Invoke Zabbix API request", "ds", ds.dsInfo.Name, "method", method)
|
ds.logger.Debug("Zabbix API request", "datasource", ds.dsInfo.Name, "method", method)
|
||||||
var result *simplejson.Json
|
var result *simplejson.Json
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -449,7 +447,7 @@ func (ds *ZabbixDatasourceInstance) getHistotyOrTrend(ctx context.Context, query
|
|||||||
history := History{}
|
history := History{}
|
||||||
err = json.Unmarshal(pointJSON, &history)
|
err = json.Unmarshal(pointJSON, &history)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ds.logger.Warn(fmt.Sprintf("Could not map Zabbix response to History: %s", err.Error()))
|
ds.logger.Error("Error handling history response", "error", err.Error())
|
||||||
} else {
|
} else {
|
||||||
allHistory = append(allHistory, history...)
|
allHistory = append(allHistory, history...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func main() {
|
|||||||
ds := Init(pluginLogger, mux)
|
ds := Init(pluginLogger, mux)
|
||||||
httpResourceHandler := httpadapter.New(mux)
|
httpResourceHandler := httpadapter.New(mux)
|
||||||
|
|
||||||
pluginLogger.Debug("Starting Zabbix backend datasource")
|
pluginLogger.Debug("Starting Zabbix datasource")
|
||||||
|
|
||||||
err := backend.Serve(backend.ServeOpts{
|
err := backend.Serve(backend.ServeOpts{
|
||||||
CallResourceHandler: httpResourceHandler,
|
CallResourceHandler: httpResourceHandler,
|
||||||
@@ -28,7 +28,7 @@ func main() {
|
|||||||
CheckHealthHandler: ds,
|
CheckHealthHandler: ds,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pluginLogger.Error(err.Error())
|
pluginLogger.Error("Error starting Zabbix datasource", "error", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +36,9 @@ func Init(logger log.Logger, mux *http.ServeMux) *datasource.ZabbixDatasource {
|
|||||||
variableName := "GFX_ZABBIX_DATA_PATH"
|
variableName := "GFX_ZABBIX_DATA_PATH"
|
||||||
path, exist := os.LookupEnv(variableName)
|
path, exist := os.LookupEnv(variableName)
|
||||||
if !exist {
|
if !exist {
|
||||||
logger.Error("could not read environment variable", variableName)
|
logger.Debug("Could not read environment variable", variableName)
|
||||||
} else {
|
} else {
|
||||||
logger.Debug("environment variable for storage found", "variable", variableName, "value", path)
|
logger.Debug("Environment variable for storage found", "variable", variableName, "value", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
ds := datasource.NewZabbixDatasource()
|
ds := datasource.NewZabbixDatasource()
|
||||||
|
|||||||
Reference in New Issue
Block a user