[ZBX-24754] Errors and weird values using MSSQL ODBC based template Created: 2024 Jun 28  Updated: 2025 Jul 01

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 6.0.31
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Sergio Belkin Assignee: Aigars Kadikis
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2024-07-01-11-11-39-758.png     PNG File image-2024-07-01-11-13-42-725.png     PNG File image-2024-07-01-11-18-36-159.png     PNG File image-2024-07-01-11-40-47-652.png     PNG File image-2024-07-01-11-42-11-655.png     PNG File image-2024-07-01-13-19-46-682.png     PNG File image-2024-07-01-13-20-18-728.png     PNG File screenshot-1.png     PNG File screenshot-2.png     File zbx_export_templates_mssql-odbc.yaml    

 Description   

There are errors with items such as:

  • Buffer cache hit ratio
  • Cache Hit Ratio
  • Worktables From Cache Ratio

Error happens on preprocessing steps using parameter, for example
**
Code:
$[?(@.counter_name=='WorktablesFromCacheRatio')].cntr_value.first()
it fails with this message:

**

 Preprocessing failed for: [{"object_name":"SQLServer:Access Methods","cntr_value":"828","counter_name":"AU cleanup batches/...

1. Failed: cannot extract value from json by path "$[?(@.counter_name=='WorktablesFromCacheRatio')].cntr_value.first()": no data matches the specified path

 
One can modifies preprocessing steps to:
 

$[?(@.counter_name=='Worktables From Cache Ratio')].cntr_value.first()

 

Now it get values but I think they are miscalculated:

 

 



 Comments   
Comment by Aigars Kadikis [ 2024 Jul 01 ]

Thank you for contacting us.
Let us know a more precise version of MS SQL server:

SELECT VERSION();

The template was tested with version 2019.
The item "Worktables from cache ratio" initially gets data from "Get Access Methods counters" comes from "Get Access Methods counters". Could you temporarily enable history:

Attach full JSON as TXT.

Comment by Sergio Belkin [ 2024 Jul 01 ]

aigars.kadikis Thank you for your response.

This the MS SQL Server version:

I've enabled history,

This the Last Data:

I made the modification a few minutes ago. For now, I don't see any changes. If the history needs to be enabled, how long should it take to see the correct values?

Comment by Aigars Kadikis [ 2024 Jul 01 ]

If the host is behind a proxy, it might take up to 1h.

Comment by Sergio Belkin [ 2024 Jul 01 ]

No, the host is not behind a proxy, last values :

 

Sadly for now, the problem persists

 

Comment by Sergio Belkin [ 2024 Jul 01 ]

aigars.kadikis The problem after a few hours persists:

Just in case, I attach the template: zbx_export_templates_mssql-odbc.yaml

Comment by Sergio Belkin [ 2024 Jul 03 ]

Hi aigars.kadikis I wonder if it's available a patch or a workaround for this issue.

Thanks in advance!

Comment by Aigars Kadikis [ 2025 Jul 01 ]

Dear sbelkin 

I see the template for Zabbix 7.0 looks similar. The master item (SQL SELECT with a lot of UNIONs) contains the same items:

  • BufferCacheHitRatio
  • CacheHitRatio
  • WorktablesFromCacheRatio

There are 7 SELECT statements in total.

If the issue is relevant, see the occurrence of errors on proxy:

grep "cannot extract value from json by path.*counter_name.*cntr_value" /var/log/zabbix/zabbix_proxy.log 

It's helpful to determine whether the dependent items fail simultaneously. For example, if "WorktablesFromCacheRatio" fails, then this part did not work well in master item:

SELECT a.object_name,
  'WorktablesFromCacheRatio' AS counter_name,
  '' AS instance_name,
  cast(a.cntr_value * ISNULL((100.0 / NULLIF(b.cntr_value,0)),0) AS dec(3, 0)) AS cntr_value
FROM sys.dm_os_performance_counters a
JOIN (
  SELECT cntr_value,
    OBJECT_NAME
  FROM sys.dm_os_performance_counters
  WHERE counter_name = 'Worktables From Cache Base'
    AND OBJECT_NAME = @SQLNAME + ':Access Methods'
) b
  ON a.OBJECT_NAME = b.OBJECT_NAME
WHERE a.counter_name = 'Worktables From Cache Ratio'
  AND a.OBJECT_NAME = @SQLNAME + ':Access Methods'

If it happens frequently, we can manually open SQL client and observe how many rows are reported. Or create another dedicated "Database monitor" item in Zabbix with this small subquery.

Generated at Fri Jul 18 08:39:44 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.