louislam / uptime-kuma

A fancy self-hosted monitoring tool

Home Page:https://uptime.kuma.pet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSONata and query tests - Unclear on how to use.

icsy7867 opened this issue Β· comments

⚠️ Please verify that this question has NOT been raised before.

  • I checked and didn't find similar issue

πŸ›‘οΈ Security Policy

πŸ“ Describe your problem

I am looking at doing a HTTPS with JSON Query to test/verify.

However I am finding very little documentation on how to do this and would love a couple examples, even if simple...

The UI points to:
https://jsonata.org/

and
https://try.jsonata.org/

However, I am still unclear what the form fields are expecting. Is the GUI expecting just the regex? Or the entire MATCH function? If it requires the entire function, what is the process for putting the output? Is there a variable? If it just wants the regex, does it want the full regex? I.E /("some-test":)[0-9a-bA-D]?
https://docs.jsonata.org/string-functions#match

Maybe there is documentation for these options and how to use them, however I did not see them looking through the wiki. Would very much appreciate some support.

πŸ“ Error Message(s) or Log

N/A

🐻 Uptime-Kuma Version

1.23

πŸ’» Operating System and Arch

Ubuntu Docker Container

🌐 Browser

Chrome

πŸ–₯️ Deployment Environment

  • Runtime: Docker
  • Database: SQLlite
  • Filesystem used to store the database on: EXT4, VMWARE using SAN
  • number of monitors: 10

Thanks for asking.
Jea, the docs of jsonata are a bit unclear on how to use functions.

I (and probably they too) don't have a good idea to document this better though..
=> If you have a good idea, I think they might love a concrete proposal...

What they mean is that if you have this JSON:

{
  "a":"ababbabbcc"
}

You can select a via the selector a resulting in "ababbabbcc".

Thus if you use the function $match(a,/a(b+)/) you get

[
  {
    "match": "ab",
    "index": 0,
    "groups": [
      "b"
    ]
  },
  {
    "match": "abb",
    "index": 2,
    "groups": [
      "bb"
    ]
  },
  {
    "match": "abb",
    "index": 5,
    "groups": [
      "bb"
    ]
  }
]

If you then want to refine this query, you can use $match(a,/a(b+)/)[index=2] to get the query with "index": 2 and $match(a,/a(b+)/)[index=2].groups to get their group.

I think this resolves your question => closing as resolved.
If it is not, please feel free to comment further questions ^^