30 Commits

Author SHA1 Message Date
Wesley van Tilburg
2242654303 Wire up MODE_PROBLEMS_ALERTING in query routing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:36:08 +00:00
Wesley van Tilburg
b86330a88d datasource: add testing error to make sure its the right place 2026-01-29 09:35:37 +00:00
ismail simsek
a2f8b6433a Introduce query timeout configuration (#2157)
## Summary

Implements configurable query execution timeout controls to prevent
poorly optimized or excessive queries from consuming excessive server
resources, causing performance degradation, or crashing the Zabbix
server.

Fixes: https://github.com/grafana/oss-big-tent-squad/issues/127

## Problem

Previously, the plugin only had an HTTP connection timeout (`timeout`)
that controlled individual API request timeouts. However, a complete
query execution could involve multiple API calls and run indefinitely if
not properly controlled, potentially causing resource exhaustion.

## Solution

Added a new `queryTimeout` setting that enforces a maximum execution
time for entire database queries initiated by the plugin. Queries
exceeding this limit are automatically terminated with proper error
handling and logging.

## Testing

1. Configure a datasource with `queryTimeout` set to a low value (e.g.,
5 seconds)
2. Execute a query that would normally take longer than the timeout
3. Verify that:
   - Query is terminated after the timeout period
   - Error message indicates timeout occurred
   - Logs contain timeout warning with query details
   - Other queries in the same request continue to execute

## Notes

- `queryTimeout` is separate from `timeout` (HTTP connection timeout)
- `queryTimeout` applies to the entire query execution, which may
involve multiple API calls
- Default value of 60 seconds ensures reasonable protection while
allowing normal queries to complete
- Timeout errors are logged with query refId, queryType, timeout
duration, and datasourceId for troubleshooting
2026-01-12 15:30:31 +01:00
ismail simsek
04fca562b0 feat(backend): Add query guardrails to prevent potential issues (#2149)
## Summary

Implements query guardrails in the backend to prevent execution of
expensive or malformed queries that could impact customer environments.

Part of https://github.com/grafana/oss-big-tent-squad/issues/127

## Changes

### New guardrails added:

1. **Item ID validation** (`queryItemIdData`)
   - Validates that item IDs are non-empty
   - Validates that item IDs contain only numeric values

2. **Time range validation** (`QueryData`)
   - Validates that `From` timestamp is before `To` timestamp

3. **API method allowlist** (`ZabbixAPIHandler`)
- Only allows Zabbix API methods defined in the frontend type
`zabbixMethodName`
   - Blocks any write/delete/update operations not in the allowlist

### New files:
- `pkg/datasource/guardrails.go` - Validation functions and error
definitions
- `pkg/datasource/guardrails_test.go` - Unit tests for all validation
functions

### Modified files:
- `pkg/datasource/datasource.go` - Added time range validation
- `pkg/datasource/zabbix.go` - Added item ID validation  
- `pkg/datasource/resource_handler.go` - Added API method validation

## Reasoning
- Allowed functions might be unnecessary as we've already prevent using
those in
[types.ts](https://github.com/grafana/grafana-zabbix/blob/main/src/datasource/zabbix/types.ts#L1-L23)
but it's nice to be cautious.
- itemid and time validation is just for sanity. 
- Time range validation will be necessary in the future to warn user
agains running expensive queries.
2025-12-29 18:57:17 +01:00
Jocelyn Collado-Kuri
89ae290942 Move health check to the backend (#2120)
This PR moves the health check to backend only leaving in the frontend
the functionality to test the dbconnector datasource.

Leaving the `dbconnector.testDataSource` should be fine since the
datasource types we allow for db connection with Zabbix already are
backend datasources, and so their health requests would go through the
backend.

Verified:
Clicking test and seeing a `health` request go out.

IMPORTANT: While testing this in the UI, I found a bug with the config
editor - whenever a change is made in the UI and tested, the changes
don't take effect (i.e. disabling trends, keeps `trends` set to `true`,
enabling db connection keep `dbConnectionEnabled` set to `false` and so
on.). Created a separate
[issue](https://github.com/orgs/grafana/projects/457/views/40?pane=issue&itemId=3627315751&issue=grafana%7Coss-big-tent-squad%7C132)
to fix this

Fixes https://github.com/grafana/oss-big-tent-squad/issues/124
Fixes https://github.com/grafana/grafana-zabbix/issues/2004
2025-11-25 14:54:18 -08:00
Zoltán Bedi
4036bc585b Add compatibility workflows and integration tests (#1991)
Fixes #1986
Fixes #1994

- Updated .gitignore to include SSL certificate files.
- Introduced new GitHub Actions workflows for testing compatibility with
Zabbix versions 5.0, 6.0, 7.0, and 7.2.
- Added integration tests for Zabbix API for each version, ensuring
proper authentication and API version handling.
- Updated Docker Compose files to support SSL configuration for Zabbix
web services.
- Removed deprecated default Docker Compose and bootstrap files.
- Removed devenv for version 6.2.
2025-03-19 14:04:52 +01:00
Ivana Huckova
58902e7ed9 Release 5.0.2 with error source fix for some downstream errors (#1980)
This PR fixes error source for 2 errors:
- parsing of invalid json response should be downstream error as we
expect to receive valid json from zabbix
- no host found error should be downstream. We are bumping sdk that
includes that fix
https://github.com/grafana/grafana-plugin-sdk-go/pull/1246.

As you can see - the invalid json parsing is now downstream error
<img width="1498" alt="image"
src="https://github.com/user-attachments/assets/88028dbe-0f73-47aa-8262-5729059ce12f"
/>
2025-02-27 12:30:19 +01:00
Zoltán Bedi
c2ffd31b1a Add error source (#1954)
Fixes  #1879
2025-02-04 12:40:33 +01:00
Sriramajeyam Sugumaran
07d41ac825 updated SDK 2023-11-16 13:07:41 +00:00
Zoltán Bedi
f31fc80b2b Chore: Update grafana-plugin-sdk-go to latest (#1702) 2023-10-05 17:43:30 +02:00
lean.dev
8205f7aaf8 Support for secure socks proxy (#1650)
* Enables PDC for zabbix datasource

* 4.4.0

* Updating CHANGELOG

* Updating CHANGELOG

* Updating CHANGELOG
2023-07-25 18:54:48 +03:00
Alexander Zobnin
8b0174f8a7 Implement internal plugin metric collection 2022-04-28 13:08:53 +03:00
Alexander Zobnin
f8a843244d Remove unused debug logging 2021-09-27 17:53:55 +03:00
Alexander Zobnin
5ed80a60e7 Fix parsing timeout (use number instead of string), fixes #1254 2021-08-11 13:32:37 +03:00
Alexander Zobnin
c81a6ae8c3 Use backend queries for item id mode 2021-06-01 13:01:54 +03:00
Alexander Zobnin
7b290897e8 Fix data source settings (DisableDataAlignment) 2021-05-31 17:47:55 +03:00
Alexander Zobnin
9a63a1f70f Return multiple frames (frame per series) 2021-05-27 13:28:14 +03:00
Alexander Zobnin
3f7cabcd53 initial pipeline for functions processing 2021-05-24 17:46:49 +03:00
Alexander Zobnin
b42d665e9e Refactor: remove unused types 2021-05-19 18:15:29 +03:00
Alexander Zobnin
7d8005838c Refactor HTTP client 2021-05-19 18:08:12 +03:00
Alexander Zobnin
badecc3aae Refactor: zabbix client 2021-05-19 13:17:46 +03:00
Alexander Zobnin
762ea252b2 Separate Zabbix API and HTTP client 2021-05-19 09:49:12 +03:00
Alexander Zobnin
072c959d23 Invoke metric queries on the backend 2021-03-09 18:23:34 +03:00
Alexander Zobnin
82819b20aa Able to configure API request timeout, #1046 2020-11-10 16:39:06 +03:00
Alexander Zobnin
8e781da7bd Support TLS settings, fix #1029 2020-08-28 16:52:55 +03:00
Alexander Zobnin
013fe5c37f Refactor: use InstanceManager for managing ds instances 2020-08-28 14:40:39 +03:00
Alexander Zobnin
d6b8992433 Refine log messages 2020-08-25 13:36:36 +03:00
Alexander Zobnin
dbb4e9dfef refactor: errors 2020-06-04 12:29:37 +03:00
Alexander Zobnin
95c8e9cfa6 move cache to datasource_cache 2020-06-04 12:10:34 +03:00
Alexander Zobnin
7990613e2c reorganize packages and add tests for zabbix datasource instance methods 2020-06-04 11:43:20 +03:00