# 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
monitoring_client = OCI::Monitoring::MonitoringClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
post_metric_data_response =
  monitoring_client.post_metric_data(
    OCI::Monitoring::Models::PostMetricDataDetails.new(
      metric_data: [
        OCI::Monitoring::Models::MetricDataDetails.new(
          namespace: 'EXAMPLE-namespace-Value',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          name: 'EXAMPLE-name-Value',
          dimensions: {
            'EXAMPLE_KEY_ISYpm' => 'EXAMPLE_VALUE_N1cpRb17BQdmbglBrOr2'
          },
          datapoints: [
            OCI::Monitoring::Models::Datapoint.new(
              timestamp: DateTime.parse('2038-08-15T23:37:41.148Z'),
              value: 2374.7915,
              count: 572
            )
          ],
          resource_group: 'EXAMPLE-resourceGroup-Value',
          metadata: {
            'EXAMPLE_KEY_qG8TK' => 'EXAMPLE_VALUE_F1AgIl95K5V5Usko5rHR'
          }
        )
      ],
      batch_atomicity: 'NON_ATOMIC'
    )
  )

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