Retrieving or changing logging level

Cloudera Data Visualization Admin API provides a convenient way to manage logging levels for specific loggers, allowing you to control the verbosity of log messages as needed. It supports retrieving and changing the logging level for a specified logger within the system.

You can query the current logging level for a logger or modify it using the following API endpoints.
  • GET: /arc/adminapi/loglevel/<logger-name>
  • POST: /arc/adminapi/loglevel/<logger-name>
POST parameters

The POST endpoint expects a JSON document in the request body. The JSON document should contain a single field, level, specifying the desired log level. It accepts one of the predefined names in the Python logging module:

  • CRITICAL
  • DEBUG
  • ERROR
  • FATAL
  • INFO
  • WARN
  • WARNING
Authentication

Both API key and session-based authentication are accepted. The retrieval of the logging level does not require any special permissions. However, updating the logging level requires the sys_viewlogs permission.

  1. Use the curl command to send a GET request to the specified endpoint to retrieve the current logging level for a specific logger.
    curl -H 'content-type: application/json' -H 'authorization: apikey [***API-KEY***]' [***VIZ_URL***]/arc/adminapi/loglevel/[***LOGGER_NAME***]
    

    Make sure to replace [***API-KEY***] with your actual API key, [***VIZ_URL***] with the Cloudera Data Visualization URL, and [***LOGGER_NAME***] with the name of the specific logger you want to check.

    After executing the command, you receive a JSON response indicating the logger name and its current logging level.

  2. Review the 'level' field in the response to determine the current logging level for the specified logger.
  3. Use the curl command to send a POST request to the specified endpoint to change the logging level for a specific logger.
    Provide the desired log level in the request body.
    curl -H 'content-type: application/json' -H 'authorization: apikey [***API-KEY***]' [***VIZ_URL***]/arc/adminapi/loglevel/[***LOGGER_NAME***]
     -d '{"level":"DEBUG"}'
    

    After executing the command, you receive a JSON response confirming the changes, including the logger name and the new logging level.

  4. Verify that the 'level' field in the response now reflects the updated logging level for the specified logger.

Getting the current loglevel for the arcweb logger:

  1. Request
    curl -H 'content-type:application/json' -H 'authorization: apikey <API-KEY>'
              <VIZ_URL>/arc/adminapi/loglevel/arcweb
  2. Response
    {
      		"logger": "arcweb",
      		"level": "INFO"
    }
    

Setting the log level to DEBUG for arcweb:

  1. Request
    curl -H 'content-type:application/json' -H 'authorization: apikey <API-KEY>' <VIZ_URL>/arc/adminapi/loglevel/arcweb -d '{"level":"DEBUG"}'
  2. Response
    {
      "logger": "arcweb",
      "level": "DEBUG"
    }