Updated 2025-01-07

Scenario: Alarming on Log Data

Set up alarms for log data using Connector Hub, Logging, and Monitoring services.

This scenario involves creating a connector and an alarm. The connector (Connector Hub)  processes and moves log data from Logging to Monitoring while the alarm  fires when triggered by received log data.

Required IAM Policy

If you're a member of the Administrators group, you already have the required access to execute this scenario. Otherwise, you need access to Monitoring and Notifications.

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.

Setting Up This Scenario

Setup is easy in the Console. Alternatively, you can use the Oracle Cloud Infrastructure CLI or API, which lets you execute the individual operations yourself.

Using the Console

This section walks through creating a connector and an alarm using the Console and then updating the topic created with the alarm.

Note

Another workflow for this scenario involves creating your topic and subscriptions first, then selecting this topic when you create your alarm.

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

Using the CLI

This section walks through creating the connector, topic, subscriptions, and alarm using the CLI.

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. Create a connector: Open a command prompt and run the oci sch service-connector create command:

    Command
    oci sch service-connector create --display-name
    "<display_name>" --compartment-id <compartment_OCID> --source [<source_in_JSON>] --tasks [<tasks_in_JSON>] --target [<targets_in_JSON>]
  2. Create a topic: Open a command prompt and run the oci ons topic create command: 

    Command
    oci ons topic create --name "Alarm Topic" --compartment-id "<compartment-ocid>"
  3. To this topic, add a subscription referencing your email address. Open a command prompt and run the oci ons subscription create command:

    Command
    oci ons subscription create --compartment-id "<compartment-ocid>" --topic-id "<topic-ocid>" --protocol "EMAIL" --subscription-endpoint "john.smith@example.com"
  4. Create an alarm that defines the error threshold and references this topic as the destination: Open a command prompt and run the oci monitoring alarm create command: 

    Command
    oci monitoring alarm create --display-name "My Alarm" --compartment-id "<compartment-ocid>" --metric-compartment-id "<compartment-ocid>" --namespace "oci_computeagent" --query-text "<yourmetric>[1m].count() > 0" --severity "INFO" --destinations "<topic-ocid>" --is-enabled true

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

Using the API

This section walks through creating the connector, topic, subscription, and alarm using the API.

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. CreateTopic: Create a topic.

  3. CreateSubscription: To this topic, add a subscription referencing your email address.

  4. CreateAlarm: Create an alarm that defines the memory threshold and references this topic.

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