Scenario: Sending Metrics to Object Storage

Learn how to send metrics to a bucket in Object Storage using Connector Hub.

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

  1. Open the navigation menu and click Analytics & AI. Under Messaging, click Connector Hub.

  2. Choose the Compartment where you want to create the connector.

  3. Click Create connector.

  4. On the Create connector page, move metrics to an Object Storage buckets:

    1. Type a Connector name. Avoid entering confidential information. Example: "Metrics to Bucket"
    2. Select the Resource compartment where you want to store the new connector.
    3. Under Configure connector, select your source and target services to move log data to a metric:
      • Source: Monitoring
      • Target: Object Storage
    4. Under Configure source, select the compute instance and block volume metrics in each compartment:
      1. Metrics compartment: The first compartment containing the compute instances and block volumes you want metrics for.

      2. Namespaces: Select oci_computeagent and oci_blockstore.

      3. Click + Another compartment to add the second compartment.

      4. Metrics compartment: The second compartment containing the compute instances and block volumes you want metrics for.

      5. Namespaces: Select oci_computeagent and oci_blockstore.

    5. Skip the optional task (Configure task).
    6. 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.
  5. If you are prompted to create a policy (required for the connector to access source, task, and target services), click Create.

  6. Click Create.

    The new connector immediately begins moving metrics to the selected bucket.

Using the CLI

  1. 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"
                }
              }
            ]
          }
        }
      ]
    }
  2. 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>"
    }
  3. Create the connector using the oci sch service-connector create command:

    Example command for creating a connector
    oci 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.

Example CreateServiceConnector request
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.