Fix compatibility with Zabbix 5.4 (skip applications filter) (#1214)

* Fix queries in Zabbix 5.4 (applications not supported)

* Fix alerting queries in Zabbix 5.4
This commit is contained in:
Alexander Zobnin
2021-05-18 17:22:49 +03:00
committed by GitHub
parent 29a8bde236
commit 3410593f9e
6 changed files with 59 additions and 13 deletions

View File

@@ -167,7 +167,10 @@ func (ds *ZabbixDatasourceInstance) getItems(ctx context.Context, groupFilter st
}
apps, err := ds.getApps(ctx, groupFilter, hostFilter, appFilter)
if err != nil {
// Apps not supported in Zabbix 5.4 and higher
if isAppMethodNotFoundError(err) {
apps = []map[string]interface{}{}
} else if err != nil {
return nil, err
}
var appids []string
@@ -505,3 +508,12 @@ func isNotAuthorized(err error) bool {
strings.Contains(message, "Not authorised.") ||
strings.Contains(message, "Not authorized.")
}
func isAppMethodNotFoundError(err error) bool {
if err == nil {
return false
}
message := err.Error()
return message == `Method not found. Incorrect API "application".`
}