Scenario: Sending Metrics to Object Storage
Learn how to send metrics to a bucket in Object Storage using Connector Hub.
Required IAM Policy
If you're a member of the Administrators group, you already have the required access to complete this scenario. Otherwise, you need read access to metrics in the specified compartments.
The workflow for creating a connector with a Monitoring source includes a default policy for reading from Monitoring in the selected compartments. If you're new to policies, see Getting Started with Policies and Common Policies.
Goal
The goal of this scenario is to archive metrics data for compute instances and block volumes to an Object Storage bucket. In this scenario, the resources are in two compartments, so you'll select metrics in both compartments.
Setting Up This Scenario
Setting up this scenario involves creating a connector to move compute instance and block volume metrics (oci_computeagent
and oci_blockstore
metric namespaces) to a bucket. All metrics of these namespaces are included.
You can complete these tasks in the Oracle Cloud Infrastructure Console, CLI, or API.
Using the Console
-
Open the navigation menu and click Analytics & AI. Under Messaging, click Connector Hub.
-
Choose the Compartment where you want to create the connector.
-
Select Create connector.
-
On the Create connector page, move metrics to an Object Storage buckets:
- Type a Connector name. Avoid entering confidential information. Example: "Metrics to Bucket"
- Select the Resource compartment where you want to store the new connector.
- Under Configure connector, select your source and target services to move log data to a metric:
- Source: Monitoring
- Target: Object Storage
- Under Configure source, select the compute instance and block volume metrics in each compartment:
-
Metrics compartment: The first compartment containing the compute instances and block volumes you want metrics for.
-
Namespaces: Select
oci_computeagent
andoci_blockstore
. -
Select + Another compartment to add the second compartment.
-
Metrics compartment: The second compartment containing the compute instances and block volumes you want metrics for.
-
Namespaces: Select
oci_computeagent
andoci_blockstore
.
-
- Skip the optional task (Configure task).
- Under Configure target, select the bucket you want to move the metrics to:
- Select the Compartment that contains the bucket.
- Select the Bucket you want.
-
If you are prompted to create a policy (required for the connector to access source, task, and target services), select Create.
-
Select Create.
The new connector immediately begins moving metrics to the selected bucket.
Using the CLI
-
Define the Monitoring source for the connector: Save a file named
source.json
.Example source.json file{ "kind": "monitoring", "monitoringSources": [ { "compartmentId": "<first_compartment_OCID>", "namespaceDetails": { "kind": "selected", "namespaces": [ { "namespace": "oci_computeagent", "metrics": { "kind": "all" } }, { "namespace": "oci_blockstore", "metrics": { "kind": "all" } } ] } }, { "compartmentId": "<second_compartment_OCID>", "namespaceDetails": { "kind": "selected", "namespaces": [ { "namespace": "oci_computeagent", "metrics": { "kind": "all" } }, { "namespace": "oci_blockstore", "metrics": { "kind": "all" } } ] } } ] }
-
Define the Object Storage target for the connector: Save a file named
target.json
.Example target.json file{ "kind": "objectStorage", "bucketName": "<bucket_name>", "objectNamePrefix": "<prefix>" }
Create the connector using the oci sch service-connector create command:
Example command for creating a connectoroci sch service-connector create --compartment-id <compartment_OCID> --display-name "Metrics to Bucket" --source file://source.json --target file://target.json
For a complete list of parameters and values for CLI commands, see the CLI Command Reference.
For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.
For a complete list of flags and variable options for CLI commands, see the Command Line Reference.
For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.
Using the API
Use the CreateServiceConnector operation to create the connector.
POST /20200909/serviceConnectors
Host: service-connector-hub.us-phoenix-1.oraclecloud.com
<authorization and other headers>
{
"compartmentId": "<compartment_OCID>",
"displayName": "Metrics to Bucket",
"source": {
"kind": "monitoring",
"monitoringSources": [
{
"compartmentId": "<first_compartment_OCID>",
"namespaceDetails": {
"kind": "selected",
"namespaces": [
{
"namespace": "oci_computeagent",
"metrics": {
"kind": "all"
}
},
{
"namespace": "oci_blockstore",
"metrics": {
"kind": "all"
}
}
]
}
},
{
"compartmentId": "<second_compartment_OCID>",
"namespaceDetails": {
"kind": "selected",
"namespaces": [
{
"namespace": "oci_computeagent",
"metrics": {
"kind": "all"
}
},
{
"namespace": "oci_blockstore",
"metrics": {
"kind": "all"
}
}
]
}
}
]
},
"target": {
"kind": "objectStorage",
"bucketName": "<bucket_name>",
"objectNamePrefix": "<prefix>"
}
}
For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.