This script will pull metrics from Megaport API and push them to DataDog. It uses the the Megaport API to gather the last 30 minutes worth of mbps in/out samples. These samples are then pushed via the DataDog API. Megaport provides their metrics at ~5 minute intervals. DataDog will not care about the duplicated samples and will do a no-op.
NOTE This is only for routers of type "MCR2". If you would like to view bandwidth data from another Megaport product you will need to change the "products" address URI. Please refer to: https://dev.megaport.com/#service-metrics--2
- Megaport user and password (I would recommend creating a new read-only user for this)
- An AWS account with access to Lambda
- DataDog API key
- Linux or OS X
How to use locally
- User pyenv or venv to create a virtual environment (optional, but recommended)
- Uncomment the last line in lambda_function.py
How to create a Lambda in AWS
- Create a new Lambda in AWS
- Upload function.zip, which was created by
- Create a trigger based on a CloudWatch event and choose "schedule" then input a desired cron. I do a trigger every 5 minutes.
cron(0/5 * * * ? *)
- Create three environment variables:
MP_USERNAME. Input your sensitive values.
If you do not specific a custom metric prefix, you should see your metric as
megaport.* in DataDog. There you can make a dashboard and monitors to your liking.