Commit Graph

106 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
f91ee858df Add problems alerting query handler
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:36:08 +00:00
Wesley van Tilburg
f8ac3d7025 Add MODE_PROBLEMS_ALERTING constant
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
renovate-sh-app[bot]
3ea69e2f8e fix(deps): update module golang.org/x/net to v0.48.0 (#2176)
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [golang.org/x/net](https://pkg.go.dev/golang.org/x/net) | [`v0.46.0` →
`v0.48.0`](https://cs.opensource.google/go/x/net/+/refs/tags/v0.46.0...refs/tags/v0.48.0)
|
![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fnet/v0.48.0?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fnet/v0.46.0/v0.48.0?slim=true)
|

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

## Need help?
You can ask for more help in the following Slack channel:
#proj-renovate-self-hosted. In that channel you can also find ADR and
FAQ docs in the Resources section.

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi42NC4xIiwidXBkYXRlZEluVmVyIjoiNDIuNjQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidXBkYXRlLW1pbm9yIl19-->

---------

Signed-off-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
Co-authored-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
Co-authored-by: Jocelyn Collado-Kuri <jcolladokuri@icloud.com>
2026-01-09 10:45:48 +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
github-actions[bot]
b13d567eee chore: bump @grafana/create-plugin configuration to 5.26.4 (#2082)
Bumps
[`@grafana/create-plugin`](https://github.com/grafana/plugin-tools/tree/main/packages/create-plugin)
configuration from 4.2.1 to 5.26.4.

**Notes for reviewer:**
This is an auto-generated PR which ran `@grafana/create-plugin update`.
Please consult the create-plugin
[CHANGELOG.md](https://github.com/grafana/plugin-tools/blob/main/packages/create-plugin/CHANGELOG.md)
to understand what may have changed.
Please review the changes thoroughly before merging.

---------

Co-authored-by: grafana-plugins-platform-bot[bot] <144369747+grafana-plugins-platform-bot[bot]@users.noreply.github.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2025-09-17 20:33:12 +02: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
Sriram
e3c3c11e41 host id as alias function (#1913) 2024-11-27 10:32:48 +00:00
Ivana Huckova
53030e2141 Fix deprecated methods based on instructions 2024-09-04 14:17:02 +02: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
Alexander Zobnin
c06683cd37 Fix backend linter errors 2023-08-30 12:48:38 +02:00
Alexander Zobnin
e33812427e Add host name only if result contains multiple hosts, fixes #1335 2023-08-01 15:25:37 +02:00
Alexander Zobnin
d484934b3a Format source code 2023-08-01 11:51:58 +02:00
Alexander Zobnin
ac976945a5 Auth: Able to use API tokens for authentication (#1662)
* Auth: Able to use API tokens for authentication

* Update change log
2023-07-26 17:23:44 +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
dd6798834a Improve tags performance (#1526)
Co-authored-by: Erik De Neve <erik.de.neve@telenet.be>
2023-03-21 12:28:34 +01:00
Alexander Zobnin
cf6b19e189 Query option to override use trends option, fixes #1442 2022-12-29 14:07:02 +01:00
Alexander Zobnin
7153a83926 Fix data processing when trend data fetched from DB, closes #1445 2022-05-06 12:43:46 +03:00
Alexander Zobnin
daaf2b634d Refactor: remove unused code 2022-05-06 12:18:15 +03:00
Alexander Zobnin
84419de6f5 Fix displaying metric names and alias functions, closes #1444 2022-05-06 12:17:06 +03:00
Alexander Zobnin
c0a33f2e7e Fix show disabled items toggle, closes #1249 2022-05-04 12:08:54 +03:00
Alexander Zobnin
8b0174f8a7 Implement internal plugin metric collection 2022-04-28 13:08:53 +03:00
Alexander Zobnin
8d35c6b297 Fix percentile aggregation with $__range_series interval 2022-04-27 15:26:48 +03:00
Alexander Zobnin
f0842bfb7e Fix missing labels in response data frame 2022-04-19 17:54:36 +03:00
Alexander Zobnin
afb90c9643 Fix using units from Zabbix, #1321 2022-02-17 16:17:49 +03:00
Alexander Zobnin
f4fad8d58d Fix alerting query error when query type has numeric type, fixes #1342 2022-02-16 17:20:06 +03:00
Alexander Zobnin
10c6e4a887 Remove unused models 2021-12-02 13:47:06 +03:00
Alexander Zobnin
f8a843244d Remove unused debug logging 2021-09-27 17:53:55 +03:00
Alexander Zobnin
1f98dc7f4c Skip alignment only if item interval twice less than query interval 2021-09-23 13:43:33 +03:00
Alexander Zobnin
9133b0aaed Skip data alignment if item interval less than query interval 2021-09-23 12:52:21 +03:00
Alexander Zobnin
c00a0e1c3f Fix db connection query post processing 2021-09-20 17:56:26 +03:00
Alexander Zobnin
3f77f14d05 Sort trend data, fixes #1300 2021-09-15 17:14:35 +03:00
Alexander Zobnin
fcef21b0fb Interpolate series to make stacking work properly in case of different intervals, #1211 2021-09-15 16:06:53 +03:00
Alexander Zobnin
483e2aaa83 Fix sortSeries() function, fixes #1274 2021-08-25 16:12:22 +03:00
Alexander Zobnin
ee5223f0ab Align multiple series to the same interval with interpolation, fix #1211 2021-08-25 11:19:19 +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
549b8ac95a Fix error on queries with aggregation function 2021-08-10 22:03:34 +03:00
Alexander Zobnin
00e33fcc49 Fix using value mapping from zabbix, closes #1222 2021-08-10 13:41:56 +03:00
Alexander Zobnin
915973829d Support item tags, fixes #1258 2021-08-09 14:57:49 +03:00
Alexander Zobnin
2a836b9ecd Don't align IT services data 2021-08-06 13:22:43 +03:00
Alexander Zobnin
736f05d398 Fix data alignment for db connection queries 2021-08-06 12:31:05 +03:00
Alexander Zobnin
d1f639f568 Fix data alignment on the backend 2021-08-06 11:50:06 +03:00
Alexander Zobnin
e12b8cbefb Handle db connection response on the backend 2021-08-04 18:07:38 +03:00
Alexander Zobnin
4ec5616029 Fix scoped vars for alias functions 2021-06-02 14:54:32 +03:00