Logging From Watson Studio

Recently I’ve been doing a lot of work in Watson Studio. Part of this has been to set up scheduled notebooks which run to process data into Db2 ready for visualization / exploration in Cognos. Given its important that these jobs complete I needed a way to log out information such that I could detect issues and address them in a timely fashion.

With this objective I set about looking at what I could use. As it happened I had previously been looking at the IBM Activity Tracker support for Watson Studio which had laid down a LogDNA instance in my account so I decided to explore my options around leveraging this as it would also provide me with a framework to process logs and drive notifications if things go wrong.

Having decided on the target I needed to figure out the “how”. A little bit of digging into the LogDNA manual quickly revealed that I could generate a log “Ingestion” key and use this to call the log ingestion API. Armed with this information I set about enabling this in my notebooks. First I created a function at the start of my notebook to handle “logging” within the wider notebook.

From the above you can see that I defined a function called LogDNA which had three required parameters covering:

  • The application name that log record is for
  • The level of the log message (info, warn, error etc)
  • The actual message
  • The ingestion key

In addition I added two additional parameters which are needed for the underlying API call but can be provided as defaults. These were:

  • The user agent name to use within LogDNA — I defaulted this to WatsonStudio as this is the system generating the log data
  • The target URL for the LogDNA instance — I defaulted this to the IBM Service endpoint for LogDNA

Finally within this cell I declared two variables:

  1. ingest_key — to hold the ingestion key for my LogDNA service (this is generated within LogDNA under the Organisation — API Keys section)
  2. app — the name of this application

With all this in place all I needed to do was call my LogDNA function where ever I needed to log “stuff” e.g.

The results in LogDNA looked as follows (nb: I’ve masked out the SQL):

So I now have a simple and clean way to output records to LogDNA, my next task is to look at how I can use LogDNA to monitor these logs.

--

--

--

I‘ve worked for IBM all of my career and I am an avid technologist who is keen to get his hands dirty. My role affords me this opportunity and I share what I can

Recommended from Medium

The Role Of Microservices Architecture In Digital Transformation Journey

Using Email connector with Wso2 MI

[Leet Code] Reverse String

Vulnhub-Symfonos

Feature oriented architecture for web applications

Aggregate Functions Part 1: COUNT() — With examples in MySQL

Sharing Power BI reports with authenticated users through our web application

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
Tony Hickman

Tony Hickman

I‘ve worked for IBM all of my career and am an avid technologist who is keen to get his hands dirty. My role affords me this opportunity and I share what I can

More from Medium

How to Work with Flyway Migration Scripts using MySQL Workbench

Redis & Redis Data Types

FHIR for Developers: Part 1

Produce and consume messages from a Kafka topic using docker