Oracle Cloud Infrastructure Resource Monitoring — Alarm triggers Notification when Metrics satisfy Condition

Oracle Cloud Infrastructure gathers metrics from all OCI resources. These metrics can be visualized and analyzed with the Metrics Explorer. And Alarms can be defined with rules evaluating the metrics that publish to a Notification Topic to signal a situation of interest. Subscriptions can be defined on these Notification Topics, to route the notifications to destinations that can be of three types: email, PagerDuty or WebHook. The latter means that a notification can be sent virtually anywhere — including to an API Gateway on OCI that routes the notification to a Function.

OCI Resources that can be observed include Functions (FaaS), Streams (Streaming Topics), Object Storage Buckets, API Gateway (Deployments) and Virtual Networks. Each resource or metrics namespace produces a different set of metrics. The next figure gives an overview of the metrics for each type of resources:

Conditions are defined using a streaming query language (Monitoring Query Language, MQL) that uses aggregation operators applied to time intervals.

Using these conditions, we can create alarms that are triggered when something happens (a lot) and also when something does not happen (as much). We can make these alarms publish to a notification topic and create a subscription that sends an email as a result.

I will now show a simple example of an Alarm [+ Notification Topic + Subscription] that results in an email when a function is invoked.

Example Alarm — Sending an Email when a Function is invoked More then X times per Time Interval

The next figure shows the set up in this example: Function hello is observed; the metric that counts the number of invocations of the function is used in a rules: the number is aggregated over 1 minute and every time that aggregation produces a value larger than 0 (meaning: the function was executed at least once), the alarm is triggered. This by itself does not really mean anything or at least does not automatically results in any action being taken.

The Alarm is associated with a Notification Topic called HelloExecutionTopic . Whenever the Alarm is triggered, it will publish a message on this topic. Subsequently, a subscription is created on this topic. It has a destination of type Email, and the email address provided is my own. The entire flow: when function hello is invoked, after at most one minute the Alarm is triggered, a notification event is published on HelloExecutionTopic and and email is sent to my email address, notifying me of this momentous event.

The steps I went through on OCI to set this up. Note: the Function Hello was already there (and I know its OCID).

  • Create Alarm Definition — using the function invocation count metric for function Hello — aggregating per minute
  • Create Notification Topic and associate Alarm Definition with this Topic
  • Create a Subscription on the Notification Topic — configured with my email address
  • Confirm the subscription of my email address my responding to a confirmation email sent to my email account

And then to see some action:

  • invoke function hello
  • wait for the email to arrive that tells me about the fact that there has been a minute during which at least one function call was made to hello

In more detail:

The Alarm Definition is composed from a number of elements:

  • Name, Severity and Body
  • Resource Type and Scope (FaaS , lab-compartment), Metric (FunctionInvocationCount), Interval (1m) and Statistic (Sum)
  • Resource (metric dimension) resourceId (OCID for function hello) Note: I tried to work with resourceDisplayName as Dimension and lab1:hello as as Dimension Value; however, that did not seem to work — the Alarm was not triggered
  • Trigger Rule: > 0 (after at least 1 minute) — if the sum of the function invocation count for lab1:hello over 1 minute is greater than 0 i.e. if function hello is invoked, then trigger this alarm

The notification topic HelloExecutionTopic:

The Alarm is associated with the Notification Topic:

And a subscription is created on the topic — with email destination type:

After this subscription is created, I received an email, inviting me to confirm the subscription of this email address on the Notification Topic:

I confirmed as invited. And now I am ready to receive the notification emails when the hello function is invoked.

And… Action

Invoke function hello (via API Gateway):

And sure enough, I receive an email that advises me of the fact that the alarm was triggered:

Of course there are far more interesting events to raise alarms for than the fact that a function is invoked. And there are more interesting things to do with the event raised by the alarm than sending an email; through the WebHook that we can have invoked, we can perform all kinds of automated actions. Note that OCI Monitoring also supports custom metrics.

Originally published at on February 3, 2020.




Lucas Jellema is solution architect and CTO at AMIS, The Netherlands. He is Oracle ACE Director, Groundbreaker Ambassador, JavaOne Rockstar and programmer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Studying APK reverse engineering by breaking the anonymity of BlindSpot app

Merkle Trees: The Backbone of Distributed Software

Protecting Your RDS: Configure Your First VPC

A Guide to Groovy DSL: Configuration

Why Stoicism can transform you in a more collaborative programmer?

What they publish: This women’s site is primarily, but

This Is How I Got Through 2020

Phase 2 — Negative Pickup

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lucas Jellema

Lucas Jellema

Lucas Jellema is solution architect and CTO at AMIS, The Netherlands. He is Oracle ACE Director, Groundbreaker Ambassador, JavaOne Rockstar and programmer

More from Medium

Easy way to display different data in OCI Dashboards

Shared File System (NFS) on Oracle Cloud Infrastructure

Observability Guide#03

Store a sensitive kubeconfig with Kubernetes and clouds providers