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

PropertyDescription
Command typeProcessing query
Required permissionAdministrator
License usageN/A
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

... | sonar-enable-logger-batch [run=BOOL]

Options

run=BOOL
Calls the collector enable API for real only when specified as t (default: f). If not specified, or if f, it behaves as a dry run that only checks whether the target collector exists, without actually enabling it.

Input fields

FieldTypeRequiredDescription
guidstringRequiredThe 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.

FieldTypeDescription
statusstringProcessing result. success or failure. On success, added only when run=t
_errorstringError message. Added only when an error occurred

Error codes

Parsing errors
Error codeMessageDescription
300143No permission to enable loggersRun by an account without administrator permission
Runtime errors
Error codeMessageDescriptionPost-action
-Invalid UUID string: [value]The guid field value is not in valid GUID formatAborts 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 guid field is missing, it adds a guid field is required message to the _error field and forwards the record. If run=t, the status field is also set to failure; if run is not specified, the status field is not added.
  • If no collector exists for the guid, it sets both _error and status=failure regardless of the run option 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 _error and sets status=failure; on success, it sets status=success.
  • If the target collector exists and run is not t (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

  1. Preview the enable target (dry run)

    json "[{'guid': '550e8400-e29b-41d4-a716-446655440000'}]"
    | sonar-enable-logger-batch
    

    Checks only whether the target collector exists, without actually enabling it.

  2. Actually enable a collector

    json "[{'guid': '550e8400-e29b-41d4-a716-446655440000'}]"
    | sonar-enable-logger-batch run=t
    
  3. Query disabled collectors and enable them in bulk

    sonar-loggers
    | search enabled == false
    | sonar-enable-logger-batch run=t
    | fields guid, name, status, _error
    

    Queries 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.