how to parse json and create trigger based on incoming json data

1.9k views Asked by At

Hi I want to monitor postgres database using ODBC and to show notification based on condition, I'm creating item with db.odbc.get[,{$DSN_NAME}], please find the screen shot my item configuration.

enter image description here

I can be able to get data, please find the below screen of receiving data enter image description here

Now I want to process this data and to show notification for user that these jobs are failed if status equals 8, I have tried it with trigger, but I can't get rid of it.

please find the screen shot for trigger configuration and also error that has been occured

enter image description here

The following error is occured

enter image description here

Can any one help me on this, and also please correct me if my approach is wrong, since I'm very new for this.

I'm also trying with low level discovery, but I don't exact way of doing it, I have tried below where I'm facing the following issue that

  Cannot create item: item with the same key "db.odbc.select[testing_odbc {#job_name},{$DSN_NAME}]" already exists.
.

Find the screen shot of discovery rule below enter image description here

Then I'm creating item prototype as below enter image description here

please find the sample data from discovery rule

{ 
  "data":[{"job_name":"job1","job_status":1},{"job_name":"job2","job_status":0},{"job_name":"job3","job_status":2}]
}

I'm scheduling the discovery rule for every 20 seconds and item prototype for every 30 seconds, and I guess for every 20 seconds it's trying to create item with same id as before.

How to resolve and for the sql query in item prototype what need to give.

1

There are 1 answers

7
Iron Bishop On

That JSON text is not a number, so you can't compare it to a number.

Options:

  • change your query to return a number.
  • Use JSONPath preprocessing to select the number from the JSON (ie: $[0]["Status"])