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:
@@ -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".`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user