Dynamic threshold

Hello

I’m trying to write an alert rule using two databases: influxdb and postgresql db.

The influxdb has the collected data and the postgres db has a threshold value.

A Query => colledted data
B Query (add) => postgres threshold value
C (expression) => Math

I want to sound the alarm when A is more than the value of B.

Is the way I thought it was wrong?

The process of creating a B query is also problematic. The following error occurs.

“Failed to evaluate queries and expressions: failed to execute conditions: input data must be a wide series but got type not (input refid)”

I would like to know what I can do to fix that issue.

B Query =>

	SELECT
	  now() as time, warning, critical
	FROM
	  threshold
	WHERE
	  stat_name = 'Write Buffer'

Welcome to the forum.

I would suggest you query your Postgres DB via this Query PostgreSQL | Flux 0.x Documentation and then follow example 5 in this tutorial: How to create Grafana alerts with InfluxDB and the Flux query language | Grafana Labs

Hello,

Now I’m using influx ql. Do I have to use flux to solve the above problem?
And referring to the tutorial you sent me, can’t I substitute a value from another datasource other than a fixed number in the calculation formula?

1 Like

Yes, I believe that you must use flux in order to query postgres.

My understanding is that you can use two queries from two different data sources when configuring an alert. Maybe you can start with simpler queries and see if it works?

I think I asked the wrong question.

Two datasources meant comparing two datasources.

example>
tutorial >> $B < 30 || $B > 60
i want >> $A > $B

B is the comparison.

That appears to be most similar to example 2 in the tutorial. Your expression would be

$C > $D

C comes from A. A comes from Influx.
D comes from B. B comes from Posteges