<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: madalinfasie</title>
    <description>The latest articles on DEV Community by madalinfasie (@madalinfasie).</description>
    <link>https://dev.to/madalinfasie</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F272604%2Fe61373d4-5f6f-4cee-83d5-641099246f93.jpeg</url>
      <title>DEV Community: madalinfasie</title>
      <link>https://dev.to/madalinfasie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/madalinfasie"/>
    <language>en</language>
    <item>
      <title>Metrics Monitoring App with Anomaly Detection using MongoDB</title>
      <dc:creator>madalinfasie</dc:creator>
      <pubDate>Thu, 23 Dec 2021 06:14:10 +0000</pubDate>
      <link>https://dev.to/madalinfasie/metric-monitoring-app-with-anomaly-detection-using-mongodb-3hd4</link>
      <guid>https://dev.to/madalinfasie/metric-monitoring-app-with-anomaly-detection-using-mongodb-3hd4</guid>
      <description>&lt;h3&gt;
  
  
  Overview of My Submission
&lt;/h3&gt;

&lt;p&gt;Schedule metric collectors to gather measurements from different external services and optionally run anomaly detection on the new values.&lt;/p&gt;

&lt;p&gt;The project uses MongoDB as a storage system, storing data as time series entries.&lt;/p&gt;

&lt;p&gt;To make the experience complete, a visualization tool is needed. Fortunately, Mongo gives us Mongo Charts which can be used directly from Mongo Atlas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Prime Time&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Link to Code
&lt;/h3&gt;

&lt;p&gt;The code can be found here: &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/madalinfasie" rel="noopener noreferrer"&gt;
        madalinfasie
      &lt;/a&gt; / &lt;a href="https://github.com/madalinfasie/monitoringapp_mongodb" rel="noopener noreferrer"&gt;
        monitoringapp_mongodb
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Metric Monitoring App Using Mongo Time Series&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Description&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Schedule metrics collectors for different services and run anomaly detection on new values.&lt;/p&gt;

&lt;p&gt;This app has been developed for the MongoDB Hackathon on Dev.to and won the &lt;a href="https://dev.to/devteam/congrats-to-the-mongodb-atlas-hackathon-winners-4cc0" rel="nofollow"&gt;runner-up prize&lt;/a&gt;.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Getting started&lt;/h2&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Prerequisites&lt;/h3&gt;

&lt;/div&gt;

&lt;p&gt;Make sure you have Docker and Docker Compose installed on your machine.&lt;/p&gt;

&lt;p&gt;Create a MongoDB Atlas cluster with MongoDB 5.0 or above installed.&lt;/p&gt;

&lt;p&gt;For security reasons, the &lt;code&gt;.env&lt;/code&gt; was not included in the repository. The available configuration variables are provided inside &lt;code&gt;.env.sample&lt;/code&gt;. Make sure to set all the configuration variables before running the app.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Running the app&lt;/h3&gt;

&lt;/div&gt;

&lt;p&gt;Running this app is as easy as running:&lt;/p&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;$ docker-compose build
$ docker-compose up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;Starting with the &lt;code&gt;docker-compose.yml&lt;/code&gt; file, we can see that this application is split into a main webapp service and the scheduling service (&lt;code&gt;celery&lt;/code&gt; in this case).&lt;/p&gt;

&lt;p&gt;The metrics collection is done mainly by the &lt;code&gt;celery&lt;/code&gt;…&lt;/p&gt;
&lt;/div&gt;


&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/madalinfasie/monitoringapp_mongodb" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
Click above to read more.

&lt;h3&gt;
  
  
  Additional Info
&lt;/h3&gt;

&lt;p&gt;To test the project, I created three metrics, two of them are randomly generated (as their name suggests) and another one is the number of Dev.to posts in the last 15 minutes (I chose 15 minutes just so I don't have to wait so long for the data). &lt;/p&gt;

&lt;p&gt;In the first screenshot, we can see the number of posts in the last 15 minutes and anther graph, plotting the values returned by &lt;code&gt;random.randrange(1, 100)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fm2vf1203f9f50ibrcm.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fm2vf1203f9f50ibrcm.PNG" alt="Dev.to Articles published last 15 minutes and a random metric"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the second screenshot, we can see the second randomly generated metric (on the right) and a plot of the anomaly prediction (on the left). It is considered an anomaly if the score is &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As you can see, due to the metric's randomness and few data points, the anomaly prediction is not giving us any real insight.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg0mmauth9pmossj7f6v.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg0mmauth9pmossj7f6v.PNG" alt="A second randomly generated metric and the anomaly detection plot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Built with
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://flask.palletsprojects.com/en/2.0.x/" rel="noopener noreferrer"&gt;Flask&lt;/a&gt;: Flask is a lightweight WSGI web application framework&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.mongodb.com/manual/core/timeseries-collections/" rel="noopener noreferrer"&gt;MongoDB&lt;/a&gt;: An open-source NoSQL database developed for high performance, high availability, and easy scalability. It also provides Time Series collections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.celeryproject.org/en/stable/" rel="noopener noreferrer"&gt;Celery&lt;/a&gt;: A task queue with focus on real-time processing, while also supporting task scheduling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;: An open platform for developing, shipping, and running applications&lt;/p&gt;

&lt;p&gt;&lt;a href="https://scikit-learn.org/stable/" rel="noopener noreferrer"&gt;scikit-learn&lt;/a&gt;: Simple and efficient tools for predictive data analysis&lt;/p&gt;

</description>
      <category>atlashackathon</category>
      <category>python</category>
      <category>mongodb</category>
      <category>monitoring</category>
    </item>
  </channel>
</rss>
