top of page

LBSocial

Writer's pictureXuebin Wei

Building a Serverless Dashboard for Real-time Social Media Data Analysis

Updated: Sep 24


 


In this video tutorial, you'll learn how to create a serverless dashboard to analyze and visualize social media data in real-time using AWS Lambda functions and MongoDB.

Create Lambda functions

  1. Open AWS Console. Search and open AWS Lambda Service.

  2. Create the first Lambda function

    1. Name: collect_tweets

    2. Runtime: python 3.9

    3. Leave everything else as default and create the function

  3. Upload the collect_tweets.zip

  4. In Configuration/General configuration:

    1. Memory: 500 MB

    2. Ephemeral storage: 1000 MB

    3. Timeout: 1 min

  5. In Configuration/Environment variables, create the following variables and provide corresponding values:

    1. api_key

    2. api_secret

    3. access_token

    4. access_secret

    5. mongodb_connect

    6. database_name

    7. geocode

    8. q_parameter

  6. In Test, create a new event to test the function.

  7. If the test is successful, add a trigger:

    1. Source: EventBridge

    2. Create a new rule

    3. Name: every5min

    4. Schedule expression: rate(5 minutes)

  8. Create the second Lambda function

    1. Name: sentiment_tweets

    2. Runtime: python 3.9

    3. Leave everything else as default and create the function

  9. Upload the sentiment_tweets.zip

  10. In Configuration/General configuration:

    1. Memory: 500 MB

    2. Ephemeral storage: 1000 MB

    3. Timeout: 1 min

  11. In Configuration/Environment variables, create the following variables and provide corresponding values:

    1. mongodb_connect

    2. database_name

    3. lang

  12. In Test, create a new event to test the function.

  13. If the test is successful, add a trigger:

    1. Source: EventBridge

    2. Use existing rule: every5min

Create a MongoDB Dashboard

  1. Log in to the MongoDB website and find the database that contains the collected tweets.

  2. Open MongoDB Chart and add a dashboard. Use the final project database as the data resource. Create the following charts and add filters to all charts to show the data from the last 60 minutes.

    1. A number chart to show the total number of collected Tweets

    2. A line chart shows the number of tweets with different sentiments over time. Use the local time zone.

    3. A word cloud to show the top 50 popular hashtags

    4. A bar chart to show the top 10 active Twitter users

    5. A table to show the Twitter texts, number of favorites, positive scores, and negative scores.



79 views0 comments

Comments


bottom of page