Skip to content

Conversation

@jcolladokuri
Copy link
Contributor

@jcolladokuri jcolladokuri commented Nov 20, 2025

This PR migrates the use of DatasourceApi to DatasourceWithBackend, with this a couple additional improvements were made:

  1. Migrate to use interpolateVariablesInQuery everywhere instead of the custom replaceTemplateVariables we were using
  2. Moves util functions out of datasource.ts and into the existing utils.ts
  3. Removes a couple uses of Select and uses ComboBox instead.
Screenshot 2025-11-20 at 11 37 56 AM

Now we can see the query calls being made to the backend:
Screenshot 2025-11-20 at 11 38 18 AM

Tested:

  • By running queries from Explore and Dashboards (with and without variables)
  • By interacting with all the different Editors to make sure ComboBox was working as expected

Next:
Once this is merged, we will next be able to slowly move away from using the ZabbixConnector to make backend datasource calls.

Fixes: #131

@jcolladokuri jcolladokuri requested a review from a team as a code owner November 20, 2025 19:39
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Levitate is-compatible report:

🔍 Resolving @grafana/data@latest...
🔍 Resolving @grafana/ui@latest...
🔍 Resolving @grafana/runtime@latest...
🔍 Resolving @grafana/schema@latest...
🔍 Resolving @grafana/e2e-selectors@latest...
🔍 Resolving @grafana/experimental@latest...

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/data version 12.1.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/ui version 12.1.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/runtime version 12.1.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/schema version 12.1.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/e2e-selectors version 12.1.0 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
Skipping package @grafana/experimental because it is not used in the project or not installed locally.
did you forget to run yarn install or npm install?

✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/schema,@grafana/e2e-selectors,@grafana/experimental

Comment on lines +23 to +27
const [interpolatedQuery, setInterpolatedQuery] = useState<ZabbixMetricsQuery>(query);
useEffect(() => {
const replacedQuery = datasource.interpolateVariablesInQueries([query], {})[0];
setInterpolatedQuery(replacedQuery);
}, [query]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know why we need to interpolate the query in here just yet, but I see this in some other places too. As this is being repeated I think it's good idea to create a custom hook to handle this. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants