Query and Code Editor
Use the query and code editor to configure script blocks. It works similarly to the formula editor used when working with dashboards.
In the editor, you can edit:
- SQL queries for blocks that interact with databases
- JavaScript code in the Execute code block from the JavaScript package
To open the editor in full screen, click the Expand icon.
Hover over a mapping field or column to see its data type. If the data type is not supported by the system, a message will appear: Will be converted to String.
To work with text, you can use the context menu. To open it, click the icon with three lines in the upper left corner.
The right side of the editor displays the visual mapping panel. It contains several tabs for searching and inserting data into the code. To insert a component from the right panel into the text field, click on it.
To add the entire table, click its name.
After editing the query or code, click Save.
Tables and Columns
The Tables and Columns tab displays tables from the database.
To use a table and its columns, first add it to the right panel. Use the search bar to find a specific table.
Columns appear only after a table is selected. The list shows recent values next to each column. If a column is empty, its data type will be shown. To find a column, select a table and enter its name in the search field.
To insert the name of a column or table into a query, click it.
You can also use autocomplete for tables and columns already added to the right panel. Just start typing the name and press Ctrl+Space. If there are multiple matches, they will appear in a dropdown. If there is only one match, it will be inserted automatically.
Tag Tree
The Tag Tree tab displays available mapping fields from previous blocks.
Use the search bar to quickly locate a field.
System Variables
The System Variables tab appears if global variables exist in the system.
The activity_table Variable
The activity_table variable provides universal access to the monitoring_activity table, which stores user activity data on monitored computers. It allows you to:
- Reference the
main.monitoring_activitytable without specifying the full path - Keep scripts functional when migrating data to another ClickHouse server
This variable is only used in automation scripts.
The value of the activity_table variable is set in the configuration file com.operavix.subsystem.monitoring.json via the monitoring_database_name and storage_guid parameters.
Using this variable provides flexibility and reduces the risk of errors when infrastructure changes:
- Directly referencing
monitoring_activityties scripts to a specific database and server. If the table is moved, you will need to update the path manually - Using the activity_table variable allows dynamic referencing based on configuration. When storage settings change, scripts using the variable automatically point to the new location
Scripts will continue to work with a hardcoded path as long as the table remains in the same location. If the location changes, use the variable to ensure scripts still function properly.
You can insert the variable via visual mapping or manually as ${global.activity_table}. For example:
SELECT * FROM ${global.activity_table}
The activity_table variable can be freely used in any automation block that requires access to the activity table.
Find and Replace
The editor includes a built-in search feature. To find a value in the text, select Find from the context menu. A search field will appear.
To replace found values, choose the Find and Replace option from the menu, enter a value, and click one of the arrow buttons next to the Replace field. A single arrow replaces only the selected value; a double arrow replaces all matching values at once.
Keyboard Shortcuts
You can use the following keyboard shortcuts when working with visual mapping:
| Windows/Linux | Mac | Description |
|---|---|---|
| Ctrl+A | Cmd+A | Select all |
| Ctrl+X | Cmd+X | Cut |
| Ctrl+C | Cmd+C | Copy |
| Ctrl+V | Cmd+V | Paste |
| Ctrl+Z | Cmd+Z | Undo input |
| Ctrl+Shift+Z | Shift+Cmd+Z | Redo input |
| Tab | Tab | Move right |
| Shift+Tab | Shift+Tab | Move left |
| Ctrl+Shift+X | Shift+Cmd+X | Uppercase |
| Ctrl+Shift+Y | Shift+Cmd+Y | Lowercase |
| Ctrl+/ | Ctrl+/ | Single-line comment |
| Ctrl+Shift+/ | Ctrl+Shift+/ | Multiline comment |
| Ctrl+D | Cmd+D | Duplicate lines |
| Ctrl+Shift+D | Shift+Cmd+D | Delete a line |
| Ctrl+F | Cmd+F | Find |
| Ctrl+H | Option+H | Find and replace |
| Ctrl+Shift+F | Ctrl+Shift+F | Formatting |
| Ctrl+Space | Cmd+E | Autocomplete |
| Ctrl+S | Cmd+S | Save and close |
Was the article helpful?