Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom var not interpreted as numeric in filter #951

Open
gbin2265 opened this issue Dec 25, 2023 · 0 comments
Open

Custom var not interpreted as numeric in filter #951

gbin2265 opened this issue Dec 25, 2023 · 0 comments
Labels
difficulty/hard You can do this! Just ask someone for input first, please. And demand (some of) it as comment here! enhancement New feature or improvement

Comments

@gbin2265
Copy link

Hello,

Describe the bug

I created a customer variable as a numeric var.

vars.numericvar = 99

Based on this variable, I want to retrieve all services (same problem in host) that the numericvar is lower then 100.

Like : icingadb/services?service.vars.numericvar<100

the result is that he doesn't find any matches.

If I look via the format=sql option I see:

where
(sub_customvar_flat.flatname = 'numericvar')
and (sub_customvar_flat.flatvalue < 100)))

If I run the SQL directly in Postgres I get an error:

SQL Error [42883]: ERROR: operator does not exist: text < integer

This is correct because the flatvalue is a text field.

Expected behavior

I expect that if you provide a numeric value, it will be interpreted as a numeric and not as a string
For me there is a difference if you give in the filter

Numeric : icingadb/services?service.vars.numericvar<100

or

String : icingadb/services?service.vars.numericvar="100"

Possible solution

If a numeric value has been specified in the filter, the "flatvalue" will be converted to a numeric value

When I use CAST in Postgresql it correctly interprets the flatvalue as a numeric value

cast(sub_customvar_flat.flatvalue as integer) < 100

Your Environment

I am using the latest snapshot of the icinga,icingadb,icingaweb2,icingadb-web (SNAPSHOT on 16dec2023)
EDB Postgresql : 14

@nilmerg nilmerg added enhancement New feature or improvement difficulty/hard You can do this! Just ask someone for input first, please. And demand (some of) it as comment here! labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/hard You can do this! Just ask someone for input first, please. And demand (some of) it as comment here! enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants