Registry / devops / oci-monitoring

oci-monitoring

JSON →
library2.132.0jsnpmunverified

Official Oracle Cloud Infrastructure (OCI) Monitoring client for Node.js, part of the OCI TypeScript SDK (v2.132.0). Allows managing monitoring metrics, alarms, and retrieval of metric data. Requires OCI account, user with policy grants, and API signing key. Updates follow OCI SDK release cadence. Distinguishes from generic cloud monitoring SDKs by its tight integration with OCI IAM, compartment-based access control, and native support for OCI Monitoring APIs (listMetrics, postMetricData, etc.).

npm install oci-monitoring
INSTALL
IMPORT
SIG · OCI-MONITORING
O
oci-monitoring
devopsjavascriptv2.132.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MonitoringClient
import { MonitoringClient } from 'oci-monitoring'
import MonitoringClient from 'oci-monitoring'
Named export, not default. CommonJS: const { MonitoringClient } = require('oci-monitoring').
models
import * as models from 'oci-monitoring/lib/model'
import { models } from 'oci-monitoring'
models is a namespace, not a named export. Access e.g. models.Metric.
requests
import * as requests from 'oci-monitoring/lib/request'
import { requests } from 'oci-monitoring'
requests is a namespace export. Use for type definitions of request objects.

Lists metrics for a given compartment using OCI Monitoring SDK. Sets up auth from config, creates client, and calls listMetrics.

import { MonitoringClient } from 'oci-monitoring'; import { Region, SimpleAuthenticationDetailsProvider } from 'oci-common'; // Set up auth provider using config file (~/.oci/config) import { ConfigFileAuthenticationDetailsProvider } from 'oci-common'; const provider = new ConfigFileAuthenticationDetailsProvider(); const client = new MonitoringClient({ authenticationDetailsProvider: provider }); client.region = Region.US_ASHBURN_1; async function listMetrics() { const compartmentId = process.env.COMPARTMENT_ID ?? ''; const request = { compartmentId: compartmentId, name: 'cpu_utilization', namespace: 'oci_computeagent', dimensionFilters: {} }; const response = await client.listMetrics(request); console.log(response.items); } listMetrics().catch(console.error);
Debug
Known issues
breakingIn v2.x, MonitoringClient constructor requires authenticationDetailsProvider object (not just config file)
fix
Pass an AuthenticationDetailsProvider instance, e.g., from ConfigFileAuthenticationDetailsProvider.
affects: >=2.0.0
deprecatedMetricDataDetails in postMetricData now prefers explicit dimension fields instead of free-form dimensions
fix
Use typed dimension arrays instead of plain objects for dimensions in MetricDataDetails.
affects: >=2.100.0
gotchaRequests often require compartmentId even when not explicitly documented in request type
fix
Always include compartmentId in listMetrics, postMetricData, etc.
affects: >=2.0.0
gotchaError handling: many operations return Error with statusCode field, not standard HTTP error
fix
Check error.statusCode for OCI-specific status codes (e.g., 404).
affects: >=2.0.0
deprecatedUsage of RawAuthenticationDetailsProvider without proper key id
fix
Switch to ConfigFileAuthenticationDetailsProvider or ResourcePrincipalAuthenticationDetailsProvider.
affects: <2.50.0
breakingOCI SDK migrated from CommonJS to ESM in v2.132.0, breaking require() imports
fix
Use import syntax or dynamic import(). For CommonJS: const { MonitoringClient } = await import('oci-monitoring').
affects: >=2.132.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'authenticationDetailsProvider')
Missing or misconfigured auth provider passed to MonitoringClient constructor.
fix
Ensure authenticationDetailsProvider is properly created, e.g., new ConfigFileAuthenticationDetailsProvider().
Error: Missing required parameter 'compartmentId'
compartmentId not provided in request object for listMetrics/postMetricData.
fix
Add compartmentId to the request object, e.g., { compartmentId: 'ocid1.compartment.oc1..example' }.
Error: The provided key does not match the fingerprint
OCI API key fingerprint mismatch between private key and public key uploaded in OCI console.
fix
Verify the fingerprint in your config file (~/.oci/config) matches the one of the uploaded public key.
Upgrade
Version history
2.132.0latest on npm
Audit
Dependencies
oci-commonrequiredCore OCI SDK for auth, HTTP, and request signing
oci-identityoptionalOptional for fetching resource principals in some auth flows
Agent activity
8 hits · last 30 days
node
8
Resources