Different thresholds for different environments

I have a lot of stats panels, that for instance check the number of active servers etc:
image

I have a variable env, that can be production, pre-production etc.

So for production a valid number of active servers is 22, but for pre-prod this is 18.
Currently I have a value mapping value 22 is OK, color green. 18 is OKpre-prod, color orange.

So if you select production and there are 22 active servers, the value will be OK.
For pre-prod if it is 18 the value will be OKpre-prod.

What I would love:
22 is OK and green for production
18 is OK and green for pre-production
18 is ERROR and red for production

Please bare in mind, I have a lot of these stats panels with different thresholds.

Anyone any solution?

hello @drj if you are using value mapping there is no option for conditions you use transformation or if you are using postgresql like database ,add conditions inside query like this …

SELECT
  actual_value,
  environment,
  CASE
    WHEN environment = 'production' AND actual_value = 22 THEN 'OK'
    WHEN environment = 'pre-prod' AND actual_value = 18 THEN 'OK'
    ELSE 'ERROR'
  END AS status
FROM server_status
WHERE environment = '${env}'
  AND metric_name = 'active_servers'

and then use value mapping


@infofcc3 Thanks for the reply and your time. I’m using elastic as a source. Any solution for that?