Top.Mail.Ru
Query and Code Editor
CTRL+K

Query and Code Editor

In this article
  • Query and Code Editor
  • Tables and Columns
  • Tag Tree
  • System Variables
  • The activity_table Variable
  • Find and Replace
  • Keyboard Shortcuts

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.

Open editor

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.

Data type

To work with text, you can use the context menu. To open it, click the icon with three lines in the upper left corner.

Open context menu

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.

Insert column

To add the entire table, click its name.

Inserting a table

After editing the query or code, click Save.

Tables and Columns

The Tables and Columns tab displays tables from the database.

Tables and Columns

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.

Search column

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.

Autocomplete

Tag Tree

The Tag Tree tab displays available mapping fields from previous blocks.

Use the search bar to quickly locate a field.

Tag Tree

System Variables

The System Variables tab appears if global variables exist in the system.

System Variables

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_activity table without specifying the full path
  • Keep scripts functional when migrating data to another ClickHouse server
Note

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_activity ties 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
Advice

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.

Search

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.

Find and Replace

Keyboard Shortcuts

You can use the following keyboard shortcuts when working with visual mapping:

Windows/LinuxMacDescription
Ctrl+ACmd+ASelect all
Ctrl+XCmd+XCut
Ctrl+CCmd+CCopy
Ctrl+VCmd+VPaste
Ctrl+ZCmd+ZUndo input
Ctrl+Shift+ZShift+Cmd+ZRedo input
TabTabMove right
Shift+TabShift+TabMove left
Ctrl+Shift+XShift+Cmd+XUppercase
Ctrl+Shift+YShift+Cmd+YLowercase
Ctrl+/Ctrl+/Single-line comment
Ctrl+Shift+/Ctrl+Shift+/Multiline comment
Ctrl+DCmd+DDuplicate lines
Ctrl+Shift+DShift+Cmd+DDelete a line
Ctrl+FCmd+FFind
Ctrl+HOption+HFind and replace
Ctrl+Shift+FCtrl+Shift+FFormatting
Ctrl+SpaceCmd+EAutocomplete
Ctrl+SCmd+SSave and close

Was the article helpful?

Yes
No
Previous
Event Processing
We use cookies to improve our website for you.