# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

require 'oci'

# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config

# Initialize service client with default config file
logging_client = OCI::Logging::LoggingManagementClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
create_unified_agent_configuration_response =
  logging_client.create_unified_agent_configuration(
    OCI::Logging::Models::CreateUnifiedAgentConfigurationDetails.new(
      display_name: 'EXAMPLE-displayName-Value',
      is_enabled: false,
      service_configuration:
        OCI::Logging::Models::UnifiedAgentMonitoringConfigurationDetails.new(
          configuration_type: 'MONITORING',
          application_configurations: [
            OCI::Logging::Models::UnifiedAgentOpenmetricsTailConfigurationDetails
              .new(
              source_type: 'TAIL',
              sources: [
                OCI::Logging::Models::UnifiedAgentTailLogSource.new(
                  source_type: 'LOG_TAIL',
                  name: 'EXAMPLE-name-Value',
                  paths: %w[EXAMPLE--Value],
                  parser:
                    OCI::Logging::Models::UnifiedAgentGrokParser.new(
                      parser_type: 'GROK',
                      patterns: [
                        OCI::Logging::Models::GrokPattern.new(
                          pattern: 'EXAMPLE-pattern-Value',
                          name: 'EXAMPLE-name-Value',
                          field_time_key: 'EXAMPLE-fieldTimeKey-Value',
                          field_time_format: 'EXAMPLE-fieldTimeFormat-Value',
                          field_time_zone: 'EXAMPLE-fieldTimeZone-Value'
                        )
                      ],
                      field_time_key: 'EXAMPLE-fieldTimeKey-Value',
                      types: {
                        'EXAMPLE_KEY_JH9jR' =>
                          'EXAMPLE_VALUE_asU7jwQnF5JlS7CqJHc9'
                      },
                      null_value_pattern: 'EXAMPLE-nullValuePattern-Value',
                      is_null_empty_string: true,
                      is_estimate_current_event: false,
                      is_keep_time_key: true,
                      timeout_in_milliseconds: 737,
                      grok_name_key: 'EXAMPLE-grokNameKey-Value',
                      grok_failure_key: 'EXAMPLE-grokFailureKey-Value'
                    ),
                  advanced_options:
                    OCI::Logging::Models::UnifiedAgentTailSourceAdvancedOptions
                      .new(is_read_from_head: false)
                )
              ],
              destination:
                OCI::Logging::Models::UnifiedAgentMonitoringDestination.new(
                  compartment_id:
                    'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
                  metrics_namespace: 'EXAMPLE-metricsNamespace-Value'
                )
            )
          ]
        ),
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      description: 'EXAMPLE-description-Value',
      defined_tags: {
        'EXAMPLE_KEY_sYBir' => { 'EXAMPLE_KEY_OqA53' => 'EXAMPLE--Value' }
      },
      freeform_tags: {
        'EXAMPLE_KEY_fMNiy' => 'EXAMPLE_VALUE_TbGGwd7DMI3BgTIjblaM'
      },
      group_association:
        OCI::Logging::Models::GroupAssociationDetails.new(
          group_list: %w[EXAMPLE--Value]
        )
    )
  )

# Get the data from response
puts "#{create_unified_agent_configuration_response.headers}"

Was this article helpful?