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

✨ feat: json-query monitor added #3253

Merged
merged 22 commits into from
Jul 13, 2023

Conversation

mhkarimi1383
Copy link
Contributor

@mhkarimi1383 mhkarimi1383 commented Jun 12, 2023

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Resolves #2431
Resolves #3163
Resolves #3299

Adding json query monitor to add json query monitor and comparing json path value with expected value

Query should be according to json-query from jsonata docs see: http://docs.jsonata.org/simple

Type of change

Please delete any options that are not relevant.

  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

image
image

Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
@mhkarimi1383 mhkarimi1383 changed the title Feat add json query ✨ feat: json-query monitor added Jun 12, 2023
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you go into if this resolves #2431 ?
(if yes: add Resolves #2431 to the description)

src/lang/en.json Outdated Show resolved Hide resolved
@CommanderStorm
Copy link
Collaborator

Another issue: json-query had its last commit in 2017 and seems abandoned.

Please go into

Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
…ryDescription element to fix `a` tags

Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
@mhkarimi1383
Copy link
Contributor Author

mhkarimi1383 commented Jun 12, 2023

Another issue: json-query had its last commit in 2017 and seems abandoned.

Please go into

* why you chose this libary

* why you think this is still a viable option and

* none of the alternatives (at least those mentioned in [library replacement auditassistant/json-query#64](https://github.com/auditassistant/json-query/issues/64)) are viable

I have just seen that this was the only option when searched for jq (json query) for JS

Now, I have switched to jsonata (Also: github and npm), I think this one is a great choice since it has more features, etc.

Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
src/lang/en.json Outdated Show resolved Hide resolved
Co-authored-by: Frank Elsinga <frank@elsinga.de>
@louislam louislam added this to the 1.23.0 milestone Jun 24, 2023
@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Jun 26, 2023

Two minor change-requests which came up in other issues:

@mhkarimi1383
Copy link
Contributor Author

My editor removed some white spaces at the end of lines ;)

Tests are getting 429 (rate limit) errors from GitHub and need retry

README.md Outdated Show resolved Hide resolved
mhkarimi1383 and others added 4 commits June 27, 2023 09:41
Co-authored-by: Frank Elsinga <frank@elsinga.de>
* Add nostr DM notification provider

* require crypto for node 18 compatibility

* remove whitespace

Co-authored-by: Frank Elsinga <frank@elsinga.de>

* move closer to where it is used

* simplify success or failure logic

* don't clobber the non-alert msg

* Update server/notification-providers/nostr.js

Co-authored-by: Frank Elsinga <frank@elsinga.de>

* polyfills required for node <= 18

* resolve linter warnings

* missing comma

---------

Co-authored-by: Frank Elsinga <frank@elsinga.de>
@mhkarimi1383
Copy link
Contributor Author

Can you please confirm my last Merge from master?

I got some conflicts that I resolved

@louislam
Copy link
Owner

Can you please confirm my last Merge from master?

I got some conflicts that I resolved

Oh, I'm apologize, I forgot I shouldn't rebase the master branch. Let me fix it.

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Jul 7, 2023

Again me:
Could you please add Resolves #3163 to the description?

@mhkarimi1383
Copy link
Contributor Author

@louislam I think I have to rebuild the package lock in this branch since it got conflicts

louislam added 3 commits July 13, 2023 23:19
# Conflicts:
#	package-lock.json
#	server/database.js
#	src/lang/en.json
#	src/pages/EditMonitor.vue
@samumatic
Copy link

The Expected Value field is only accepting one value, but if i have multiple values, it fails and states:
[DOWN] 200 - OK, but value is not equal to expected value, value was: [1]

But i want it to be up, at the values 0&1, but down at the Value 2 or else.
I didn't found any option via syntax to bypass this problem.
Help would be appreciated.

@chakflying
Copy link
Collaborator

Have you tried using expressions in jsonata?

https://docs.jsonata.org/expressions

@mhkarimi1383
Copy link
Contributor Author

The Expected Value field is only accepting one value, but if i have multiple values, it fails and states:
[DOWN] 200 - OK, but value is not equal to expected value, value was: [1]

But i want it to be up, at the values 0&1, but down at the Value 2 or else.
I didn't found any option via syntax to bypass this problem.
Help would be appreciated.

It would be great if you can change value

For example up and ok will be converted to ok

@samumatic
Copy link

Have you tried using expressions in jsonata?

https://docs.jsonata.org/expressions

Thank you for the hint, after a bit try and error i found the solution to my problem:

Json Query: ($.extensions.state = 0) or ($.extensions.state = 1)
Expected Value: true

Thank you for your fast response!

@jbates58
Copy link

Hi all, i would like to propose a feature for this, where if you get an unexpected response, and it marks the item as down, that it stores the entire JSON object so you can retrospectively look at what the error was.

I can see that it tells me what the response it got was which is fine, but the error message itself is stored in another JSON key in alot of things.

the response typically looks like this
{ "state": "unhealthy", "messages": [ "error", "mesage", "list", "here" ] }

image

@CommanderStorm
Copy link
Collaborator

please dont necropost on merged issues and have instead search for the respective issue and subscribe there ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants