Reference no: EM132285559
Assignment -
Objective: The goal of this problem is to allow engineers to learn how to interact with a REST API to generate alarms /notifications (in this case, the problem will generate an email) to a platform. Also, this exercise also allows you to learn how to include an HTTP URL report within the notification (email or alarm) so the operator can understand the notification and take actions that provides notification. In addition, you will learn how extract/read the data from a postgres databases.
We will continue using the same EPA dataset we used before for our first problem to facilitate focus on the key learnings. This dataset has 332 probes which report Sulfate and Nitrate particulate measurements in the air (the unit of the measurement is not important, thus ignore). The clean data is hosted on a postgres database - read the section "Reading Data from Postgres database using R" to learn how to access the data.
Read before attempting the problem: Assume EPA announced that it had set the limits for sulfate and nitrate in the air as follows:
sulfate_thresh = 30
nitrate_thresh = 40
It has asked the developers to create an application that monitors the measurement files and report an alert to a central location when probes report sulfate and nitrate levels above the EPA specified thresholds.
Your job is to create an application that will generate an email notification through a REST API. The application will use an "Event Router" that will facilitate the creation of the email notification. The event router MUST receive a JSON document from your application using HTTP POST with a particular format shown below.
{
"email_addr":["your_email_address@"],
"event_id":"65",
"lcc_id":"list of probes exceeding EPA limit",
"node_id":"probe ID exceeding sulfate limit: [list of comma delimited probes] probe ID exceeding nitrate limit: [list of comma delimited probes]",
"opt_data":{
"field1":"Report url",
"field2":"insert URL of Shiny report "},
"site_id":"dummy"
}
REST API (Event Router): has developed an Event Router that provides a REST API to generate alarms & events to the operator (or emails) based on HTTP POST interactions. We will use this tool for this exercise.
Reading Data from Postgres database using R
When developing production application most of the time data will be hosted on a database. You should know how to access data from a database. In this exercise you will be retrieving the data from postgres database. You will be using "RPostgreSQL" package to access the database.
Problem - USE Shiny APP
Create the following 2 applications (Note you could write this in a single app if you like)
1. An R application which generates an email notification after processing all specdata files and provides a URL link with full reporting (output of the shiny app; 2nd application) for the operator
2. An R shiny app which provides full reporting for the specdata. This task will require you to create the shiny app which expose a URL on your local computer. This URL is the address to be included in the JSON document posted to the API. Below is a quick example of the Shiny App. Be creative in a way that you want to create the reporting. This is just an example.
a. HTML text at the beginning to show the probe ID which are exceeding EPA limits
b. Slider to select the probe ID
c. Which renders a reactive plot with trend of sulfate and nitrate over time - showing EPA threshold line.
Attachment:- Assignment File.rar