sonar-log-schema-fields

Retrieves the list of fields defined in the specified log schema. You can check each field's name, display name, type, and display order.

Command properties

PropertyDescription
Command typeDriver query
Required permissionAdministrator
License usageCounted
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

sonar-log-schema-fields schema=STR [locale=STR]

Options

schema=STR (required)
The log schema code to query fields for
locale=STR
The locale to get the display name from. Specify one of ko, en, ja, or zh. If not specified, uses the locale configured for the session.

Input fields

None (as a driver query, this command can only be used as the first command in a pipeline)

Output fields

FieldTypeDescription
namestringField name
display_namestringField display name (the display name for the specified language when the locale option is applied)
typestringField type (for example, IP, STRING, DATE)
ordinalintegerDisplay order

Error codes

Parsing errors
Error codeMessageDescription
300146No permission to enumerate log schemas.Run by an account without administrator permission
300147Schema option is required.The schema option was not specified
Runtime errors
Error codeMessageDescriptionPost-action
-Schema not found: [schema]No log schema exists for the schema option valueAborts query execution

Description

The sonar-log-schema-fields command retrieves the fields defined in the log schema specified by the schema option and returns the field name, display name, type, and display order (ordinal). If the schema has no fields defined, it finishes with no results.

If you specify the locale option, the display_name field value is replaced with the display name for that language. If you specify an unsupported locale value, it is ignored and the default display name is returned; even for a supported locale, if there is no translation for that language, the default display name is used instead. If the locale option is not specified, the current session's locale setting is followed.

Examples

  1. Query the field list of a schema

    sonar-log-schema-fields schema="session"
    
  2. Query display names in English

    sonar-log-schema-fields schema="session" locale="en"
    
  3. Query only field names in display order

    sonar-log-schema-fields schema="session"
    | sort ordinal
    | fields name, display_name
    

Change history

The sonar-log-schema-fields 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.