Sensetif / sensetif-app-plugin

The Grafana Application Plugin for the Sensetif platform.
Apache License 2.0
0 stars 0 forks source link

Script Naming, References amd Parameters #73

Open niclash opened 11 months ago

niclash commented 11 months ago

This is a INFORMATIVE ISSUE, without action items.

When giving a name in the "Condition" field we need to be able to pass user-defined arguments into the script. For instance, if we have a script to check the limit of a sampled value, then the same script should be used everywhere and only different limit value passed into it.

We also need to signal the scope (global, organization and project) and the language of the script in the "condition" field in the UI, with well-defined separators, as we can execute many script on each sample.

Script URI

The Script URI solves all of this.

[language]://[scope]/[scriptName]?[parameters]

[language] is one of "js", "python" or "ruby". [scope] is one of "global", "organization" or "project", where "organization" is the default one, e.g. "js:///summerCheck" [scriptName] is the base name of the script, without any "extensions" (such as .ruby) [parameters] are regular [name]=[value] pairs separated with ampersand (&) just like query parameters in URLs.

Scripts are stored in the KeyValues store in Cassandra, under the TYPE of "scripts", and the identifier of the script is [language]:([project]/)[scriptName] to allow same scriptName in different languages. The [project] is the name of the project the script is used in, if the scope is "project", and all (incl parenthesis) are absent for the default "organization" and "global" scripts.

For the scope = global the scripts are stored under orgId=0.