sonar-enable-logger-batch
Enables a batch of collectors corresponding to the guid field value passed in the input record. If the run option is not specified, nothing is actually enabled, and you can only check in advance whether the target collectors exist.
Command properties
| Property | Description |
|---|---|
| Command type | Processing query |
| Required permission | Administrator |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
Options
run=BOOL- Calls the collector enable API for real only when specified as
t(default:f). If not specified, or iff, it behaves as a dry run that only checks whether the target collector exists, without actually enabling it.
Input fields
| Field | Type | Required | Description |
|---|---|---|---|
| guid | string | Required | The GUID of the collector to enable |
Output fields
Forwards all fields of the input record unchanged, and adds the following fields depending on the processing result.
| Field | Type | Description |
|---|---|---|
| status | string | Processing result. success or failure. On success, added only when run=t |
| _error | string | Error message. Added only when an error occurred |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 300143 | No permission to enable loggers | Run by an account without administrator permission |
Runtime errors
| Error code | Message | Description | Post-action |
|---|---|---|---|
| - | Invalid UUID string: [value] | The guid field value is not in valid GUID format | Aborts query execution |
Description
For each input record, the sonar-enable-logger-batch command looks up the target collector by the guid field value, then processes it as follows.
- If the
guidfield is missing, it adds aguid field is requiredmessage to the_errorfield and forwards the record. Ifrun=t, thestatusfield is also set tofailure; ifrunis not specified, thestatusfield is not added. - If no collector exists for the
guid, it sets both_errorandstatus=failureregardless of therunoption value. - If the target collector exists and
run=t, it actually calls the enable API. If the call fails, it records the failure reason in_errorand setsstatus=failure; on success, it setsstatus=success. - If the target collector exists and
runis nott(the default), it does not call the API and forwards the input record unchanged (a dry run).
If the guid field value is not in GUID format, it is not treated as a per-record error; query execution itself is aborted, so it is a good idea to validate the value format in advance.
Examples
-
Preview the enable target (dry run)
json "[{'guid': '550e8400-e29b-41d4-a716-446655440000'}]" | sonar-enable-logger-batchChecks only whether the target collector exists, without actually enabling it.
-
Actually enable a collector
json "[{'guid': '550e8400-e29b-41d4-a716-446655440000'}]" | sonar-enable-logger-batch run=t -
Query disabled collectors and enable them in bulk
sonar-loggers | search enabled == false | sonar-enable-logger-batch run=t | fields guid, name, status, _errorQueries all currently disabled collectors, enables them in bulk, and checks the processing result.
Change history
The sonar-enable-logger-batch command is available in the Sonar 4.0 series starting with 4.0.2609.0, where the command previously provided by the Experimental app was built into Sonar core. On versions without the built-in command, install the Experimental app to use it. The Experimental app provides it under the name sonar-enable-loggers.