// 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).
import * as opsi from "oci-opsi";
import common = require("oci-common");
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new opsi.OperationsInsightsClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const ingestHostMetricsDetails = {
items: [{
metricName: "HOST_TOP_PROCESSES", pid: 6126.382,
userName: "EXAMPLE-userName-Value",
memoryUtilizationPercent: 3290.7634,
cpuUtilizationPercent: 239.82883,
cpuUsageInSeconds: 4423.2285,
command: "EXAMPLE-command-Value",
virtualMemoryInMBs: 2431.6377,
physicalMemoryInMBs: 850.02484,
startTime: new Date("Sat Feb 17 05:09:54 UTC 2035"),
totalProcesses: 4036.895,
containerId: "ocid1.test.oc1..<unique_ID>EXAMPLE-containerId-Value",
diskBytesRead: 2473.1636,
diskBytesWritten: 9480.324,
diskIopsRead: 4889.9307,
diskIopsWritten: 4447.6543,
diskIops: 6484.0493,
timeCollected: new Date("Thu May 18 08:20:04 UTC 2028")
}
],
}
const ingestHostMetricsRequest: opsi.requests.IngestHostMetricsRequest = {
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
ingestHostMetricsDetails: ingestHostMetricsDetails,
opcRequestId: "QEEWOYAFXXMZP4VHU5WI<unique_ID>",
ifMatch: "EXAMPLE-ifMatch-Value",
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
};
// Send request to the Client.
const ingestHostMetricsResponse = await client.ingestHostMetrics(ingestHostMetricsRequest);
}
catch (error) {
console.log("ingestHostMetrics Failed with error " + error);
}
})();