Schedule Agents with Oracle Fusion Analytics Event Notifications and OCI Functions

October 18, 2023 | 7 minute read
Krishna Prasad Kotti
Senior Member of Technical Staff
Amarpreet Nagra
Principal Member of Technical Staff, Analytics Customer Excellence
Text Size 100%:

Introduction

Oracle Fusion Analytics (FAW) is an Oracle Cloud Infrastructure (OCI) native service that leverages the power of Oracle Autonomous Data Warehouse (ADW) and Oracle Analytics Cloud (OAC).  It provides a comprehensive analytics solution that includes a data pipeline, data warehouse, semantic model, and content such as dashboards and reports. Fusion Analytics extracts data from various sources, transforms it, and loads it into an ADW.

As businesses expand and develop, the importance of automation in managing data and analytics applications also grows. Based on user input, Oracle offers the FAW Event Producer service that gives you more control over tracking customized events and notifications. This service is an effective automated solution for creating consolidated events and notification workflows that can streamline your Fusion Analytics business operations. This feature is available in Preview.

To review the Event Notifications feature, see Get notified when your data refresh completes using event notifications and Features Available for Preview.

This post describes a specific use case and provides step-by-step instructions for using custom functions to send email notifications based on FAW events.

Overview of Functions

Oracle Cloud Infrastructure Functions offer a fully managed, multi-tenant, highly scalable, and on-demand Functions-as-a-Service platform. It’s built on enterprise-grade Oracle Cloud Infrastructure and powered by the Fn Project open-source engine. Use OCI Functions (sometimes abbreviated to just Functions and formerly known as Oracle Functions) when you want to focus on writing code to meet your business needs.

Functions are units coded in Java, Python, Node, Go, Ruby, and C# languages and regrouped in Applications. This example uses Python, the most widely used language for data science. Functions are stored as docker images in a specified container registry. You can invoke them in different ways:

  • Using the Fn Project CLI.
  • Using the Oracle Cloud Infrastructure CLI / Cloud Shell.
  • Using the Oracle Cloud Infrastructure SDKs.
  • Making a signed HTTP request to the function's invoke endpoint. Every function has an invoke endpoint.

Overview of OCI Vault

Oracle Cloud Infrastructure Vault is a key management service that stores and manages master encryption keys and secrets for secure access to resources. Vault lets you securely store master encryption keys and secrets that you might otherwise store in configuration files or in code. Specifically, depending on the protection mode, vault keys are either stored on the server or they're stored on highly available and durable hardware security modules (HSM) that meet Federal Information Processing Standards (FIPS) 140-2 Security Level 3 security certification.

You can use the Vault service to create and manage the following resources:

  • Vaults
  • Keys
  • Secrets

FAWAgentVault Screenshot

How do I deliver custom content through Oracle Analytics Cloud agents and OCI function based on FAW events? 

This section describes triggering OAC agents to deliver custom content based on FAW events.

Use case

You need to schedule reports so that they can be delivered directly to users. This report should be delivered to the user’s email inbox after the pipeline's daily incremental run is completed.

Prerequisites 

Create an analysis in Oracle Analytics Cloud and an agent that delivers the report content. Specify who is to receive the delivery content of the agent and who's allowed to subscribe to the agent.

Create a Vault

1.  Sign in to the OCI Console.

FAWAgentOCI Console

2. Click Identity and Security.

FAWAgentIdentity and Security

3. Click Vault.

FAWAgentOCI Vault

4. On the Vault page, click Create Vault.
    In the Create Vault dialog, select a Compartment and provide a Name.

FAWAgentCreate Vault

5. Under Master Encryption Keys, click Create Key.

FAWAgentCreate Key

6. In the Create Key dialog, select the Compartment, provide a Name, and then click Create Key.

FAWAgentCreate Key02

7.  Under Resources, click Secrets

FAWAgentSecrets

8.  Under Secrets, click Create Secret.

FAWAgentCreate Secret

9. In the Create Secret dialog, provide the Name and Description.
    In Secret Type Template, select Base64.
    In Secret Contents, provide the contents of the key, such as username or OAC URL and then click Create Secret.

FAWAgentCreate Secret02

10. Follow the steps above to create secrets for AgentUserName, AgentCredentials, AgentOACURL, and AgentPath.

FAWAgentAgent Secrets

Copy the OCID’s of the secrets that you’ll use in the function described in the next section.
Note: Ensure this user exists in the OAC instance related to Fusion Analytics and has the ability to execute the agent.

Create a function

Follow the steps described in Functions QuickStart on Cloud Shell to set up functions.
You can use code such as the following to create the function:

import base64
import oci
import io
import json
import base64
import oci
import logging
import sys
import suds
from suds.client import Client

from fdk import response

def get_text_secret(secret_ocid):
    signer = oci.auth.signers.get_resource_principals_signer()
    try:
        client = oci.secrets.SecretsClient({}, signer=signer)
        secret_content = client.get_secret_bundle(secret_ocid).data.secret_bundle_content.content.encode('utf-8')
        decrypted_secret_content = base64.b64decode(secret_content).decode("utf-8")
    except Exception as ex:
        print("ERROR: failed to retrieve the secret content", ex, flush=True)
        raise
    return {decrypted_secret_content}

def handler(ctx, data: io.BytesIO = None):
    logging.getLogger().info("function start")

# set the OCID's for the secrets in Oracle Vault which has OAC Login Credentials
    Agent_user_ocid = "<OCID of AgentUserName>"
    Agent_credential_ocid = "<OCID of AgentCredentials>"
    oac_url_oicd = "<OCID of AgentOACURL>"
    path_ocid = "<OCID of AgentPath>"

    resp = ""
    Username,Password,oac_url,path = ""

    Username = get_text_secret(Agent_user_ocid)
    Password = get_text_secret(Agent_credential_ocid)
    oac_url = get_text_secret(oac_url_oicd)
    path = get_text_secret(path_ocid)

    sourceclient = Client(oac_url)
    session_id = sourceclient.service["SAWSessionService"].logon(username,password)
    print(session_id)

    test = sourceclient.service["IBotService"].executeIBotNow(path, session_id)

    sourceclient.service["SAWSessionService"].logoff(session_id)
    print("Logoff")
    logging.getLogger().info("function end")

    return response.Response(
        ctx, response_data=json.dumps(
            {"message": "Hello {0}".format(name)}),
        headers={"Content-Type": "application/json"}
    )

Ensure that you complete all the steps needed to create an OCI function. Review the code and update the OCID's for the secrets in Oracle Vault.

Enable the FAW Event Service Feature and create the custom automation email notification

 

Call to Action

If you need a secure and reliable means to automate events and notifications for your Oracle Fusion Analytics implementation, then try the FAW Event Producer service. By subscribing to these events, you can create custom workflows and eliminate the need for ad-hoc communications such as emails and service request tickets.

You can choose to be automatically notified of important events such as the daily data pipeline completion and you can eliminate the need to constantly check the system for completion.

References
Consult these resources:
Events Service | Oracle
Overview of Notifications (oracle.com)
Overview of Functions (oracle.com)
Overview of Vault
 

Krishna Prasad Kotti

Senior Member of Technical Staff

Amarpreet Nagra

Principal Member of Technical Staff, Analytics Customer Excellence


Previous Post

Managing Permissions in Oracle Analytics Cloud

Adam Bloom | 9 min read

Next Post


Optimize Oracle Analytics Cloud Performance with Akamai Content Delivery Network

Ravi Bhuma | 3 min read