Scenario: Creating Dimensions for a Monitoring Target

Learn how to create dimensions for a custom metric generated by a connector. Send log data from the Logging service to metrics (Monitoring service) using Connector Hub.

This scenario involves creating a connector  to generate a custom metric with dimensions referencing log data. Use this connector to move log data from Logging to Monitoring. After the data is moved, you can filter the new custom metrics using the dimensions created by the connector.

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 access to Monitoring.

The workflow for creating the connector includes a default policy when needed to provide permission for writing to the target service. If you're new to policies, see Getting Started with Policies and Common Policies.

Goal

This topic describes the goal of this scenario.

The goal of this scenario is to filter update events for Object Storage buckets. For example, find updates that changed buckets to public access. Finding public buckets can help prevent leakage of secrets. In addition to public access type, this scenario sets up filters for bucket name, compartment name, availability domain, versioning status, and a static value.

Setting Up This Scenario

This topic describes the tasks involved in setting up this scenario.

This scenario creates a metric from a log using the Connector Hub service. Setting up this scenario involves the following tasks:

  • Create a connector to move logs from Logging to a custom metric with dimensions in Monitoring.

    • Log data: Bucket - Update event from audit logs (_Audit log group)

      Note

      While this scenario uses the _Audit log group and the bucket update event, you can use the same approach with any log available in your tenancy.
    • Metric namespace: bucket_events

    • Metric name: update

    • Static value buckets-from-connector (dimension name: mytags)

    • Extracted value using path dimensions:

      Note

      Each new dimension value creates a new metric stream. To avoid generating too many unique metric streams, which could potentially result in throttling, we recommend excluding GUIDs or UUIDs (such as compartment OCIDs) from the dimensions.

      Path property (dimension name) Value
      bucketName logContent.data.additionalDetails.bucketName
      compartmentName logContent.data.compartmentName
      availabilityDomain logContent.data.availabilityDomain
      publicAccessType logContent.data.additionalDetails.publicAccessType
      versioning logContent.data.additionalDetails.versioning
  • Filter the moved data with the dimensions (static and extracted values).

You can complete these tasks in the Oracle Cloud Infrastructure Console, CLI, or API.

Using the Console

This topic describes how to use the Console to set up the scenario.

For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.

Using the CLI

This topic describes how to use the CLI to create the connector and filter the moved data.

For information about using the API and signing requests, see REST API documentation and Security Credentials. For information about SDKs, see SDKs and the CLI.

  1. Define the log source for the connector: Save a file named source.json.

  2. Define the target (metric and dimensions) for the connector: Save a file named target.json.

  3. Create a connector: Open a command prompt and run the oci sch service-connector create command:

  4. Query the metric data using the custom dimensions: Open a command prompt and run the oci monitoring metric-data summarize-metrics-data command:

For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.

Using the API

This topic describes how to use the API to create the connector and filter the moved data.

For information about using the API and signing requests, see REST API documentation and Security Credentials. For information about SDKs, see SDKs and the CLI.

Use the following operations:

  1. CreateServiceConnector: Create a connector.

  2. SummarizeMetricsData: Query the metric data by dimensions.

For help with troubleshooting, see Troubleshooting Connectors and Troubleshooting Notifications.