# 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'
require 'date'

# 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
opsi_client = OCI::Opsi::OperationsInsightsClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
ingest_host_metrics_response =
  opsi_client.ingest_host_metrics(
    'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value',
    OCI::Opsi::Models::IngestHostMetricsDetails.new(
      items: [
        OCI::Opsi::Models::HostCpuUsage.new(
          metric_name: 'HOST_CPU_USAGE',
          time_collected: DateTime.parse('2036-09-15T19:27:21.544Z'),
          cpu_user_mode_in_percent: 6400.3027,
          cpu_system_mode_in_percent: 4626.908,
          cpu_usage_in_sec: 3206.843,
          cpu_utilization_in_percent: 3973.8345,
          cpu_stolen_in_percent: 9400.536,
          cpu_idle_in_percent: 7145.7773,
          cpu_load1min: 6277.1904,
          cpu_load5min: 4835.9414,
          cpu_load15min: 9601.998
        )
      ]
    )
  )

# Get the data from response
puts "#{ingest_host_metrics_response.data}"