Fix: ensure that applicationids parameter only gets passed when the datasource supports it. (#2110)

Zabbix 5.0.x supported filtering `Problems` feature with `applications`.
When this got removed, we removed the filter dropdown from the UI, but
failed to check whether applications were supported before sending out
the request with the parameters.

This was causing dashboards that had been created with zabbix version
`5.0.x` to fail when querying with newer versions of our plugin with
error: `Invalid params. Invalid parameter "/": unexpected parameter
"applicationids".`

These changes now ensure that we also check whether applications filter
should be supported before sending the backend request to fetch
problems.

How to test:
- use the attached JSON file. This was created using zabbix50 and
applying an `applicationids` filter for `Problems` query type OR

- run the `zabbix50` test environment:
    ```
       cd devenv/zabbix50
       docker-compose up -d
    ```
- create a dashboard that queries for `Problems` and filters with
applications then export the dashboard JSON
- stop the `zabbix50` test environment and start the `zabbix74` test
environment
    ```
          docker-compose stop
          cd ../zabbix74
          docker-compose up -d
     ```
- import the dashboard you created above, it should load and work as
expected.


Bottom panel was created using zabbix50 and it used the application
filter. Both panels now load as expected:
<img width="2558" height="1018" alt="Screenshot 2025-10-21 at 2 28
25 PM"
src="https://github.com/user-attachments/assets/9613d59b-3f88-420c-9897-f8d988b3d2f0"
/>

Fixes https://github.com/grafana/grafana-zabbix/issues/1852
This commit is contained in:
Jocelyn Collado-Kuri
2025-10-28 19:57:45 -07:00
committed by GitHub
parent 2d9714a4db
commit 045c708c69
5 changed files with 125 additions and 5 deletions

View File

@@ -509,7 +509,15 @@ export class Zabbix implements ZabbixConnector {
return query;
})
.then((query) => this.zabbixAPI.getProblems(query.groupids, query.hostids, query.applicationids, options))
.then((query) =>
this.zabbixAPI.getProblems(
query.groupids,
query.hostids,
query.applicationids,
this.supportsApplications(),
options
)
)
.then((problems) => {
const triggerids = problems?.map((problem) => problem.objectid);
return Promise.all([Promise.resolve(problems), this.zabbixAPI.getTriggersByIds(triggerids)]);
@@ -533,7 +541,7 @@ export class Zabbix implements ZabbixConnector {
const [filteredGroups, filteredHosts, filteredApps] = results;
const query: any = {};
if (appFilter) {
if (appFilter && this.supportsApplications()) {
query.applicationids = _.flatten(_.map(filteredApps, 'applicationid'));
}
if (hostFilter) {
@@ -579,7 +587,15 @@ export class Zabbix implements ZabbixConnector {
return query;
})
.then((query) => this.zabbixAPI.getProblems(query.groupids, query.hostids, query.applicationids, options))
.then((query) =>
this.zabbixAPI.getProblems(
query.groupids,
query.hostids,
query.applicationids,
this.supportsApplications(),
options
)
)
.then((problems) => findByFilter(problems, triggerFilter))
.then((problems) => {
const triggerids = problems?.map((problem) => problem.objectid);