ConfigurableQuery is probably not working properly
-
If I create a configuration for the Query parameter, everything works correctly. NetXMS connects to the database and the DCI returns the correct value. If I change the same Query parameter to a ConfigurableQuery parameter (and modify its value according to the documentation) and modify the metric to the query name and put a value in parentheses to replace the ? in the query, an empty result set is always returned. I have verified this on three drivers (mssql, mysql and pgsql). If I separately validate the query in another application, everything works correctly.
Configuration sample
ConfigurableQuery = Database.Data:id1:Custom data:SELECT `name` FROM `test` WHERE `description` LIKE "?"; -
You can try to run agent with DebugLevel = 6 in it's config - actual query and detail of execution should be visible in the log. Pls share the log part related to execution of the query.
-
It seems that ? is not going to be replaced by a metrics argument.
2025.04.07 13:24:03.180 *D* [comm.cs.1 ] Requesting metric "Database.Data(foo)"
2025.04.07 13:24:03.180 *D* [dbquery ] H_DirectQueryConfigurable: Executing query "SELECT `name` FROM `test` WHERE `description` LIKE "?";" in database "id1" -
Try removing quotes around the question mark:
ConfigurableQuery = Database.Data:id1:Custom data:SELECT `name` FROM `test` WHERE `description` LIKE ?;
-
Quotes removed:
2025.04.08 10:13:13.718 *D* [comm.cs.1 ] Requesting metric "Database.Data(foo)"
2025.04.08 10:13:13.718 *D* [dbquery ] H_DirectQueryConfigurable: Executing query "SELECT `name` FROM `test` WHERE `description` LIKE ?;" in database "id1"
Result is fine.
But if I add my own text to the value (e.g. LIKE %?), an error is logged You have an error in your SQL syntax.
The metric only works when I put the whole condition in the metric brackets (it must not be in the configuration file).
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login