This knowledge base explains how to enable auto scaling for Site24x7 plugins on AWS using an AMI-based approach.
In this example, we use a MongoDB monitoring plugin, where the required setup is baked into the EC2 launch process. When instances scale automatically using a launch template, the Site24x7 agent and plugin are installed and configured without manual intervention.
This ensures that new EC2 instances created through Auto Scaling Groups are monitored automatically as soon as they come online.
What the script does
The attached example startup script performs the following actions during instance launch:
- Installs the Site24x7 Linux agent.
- Downloads the required Site24x7 MongoDB plugin files. Ensure that access to the domain https://github.com/site24x7/plugins is allowed in your firewall or security rules so the required plugin files can be downloaded.
- Configures the plugin using the MongoDB connection details provided by the user.
This script is executed automatically when an EC2 instance is launched using the configured launch template.
Configuration required
Before using the script, you must update it with your Site24x7 device key and MongoDB server details.
Update the following parameters in the script:
- host = "localhost"
- port = "27017"
- username = "None"
- password = "None"
- dbname = "mydatabase"
- authdb = "admin"
- tls = "False"
- tlscertificatekeyfile = "None"
- tlscertificatekeyfilepassword = "None"
- tlsallowinvalidcertificates = "True"
Make sure the values match your MongoDB deployment and authentication setup.
Updating the AWS launch template
Once the script is updated with the correct details, follow these steps to attach it to your AWS launch template.
- Log in to the AWS Management Console.
- Navigate to EC2.
- Click Launch templates.
- Edit the required launch template.
- Under Advanced Details, upload or paste the updated startup script.
- Save the changes.
- Use this launch template when creating or updating your EC2 instances.
Any EC2 instance launched using this template will:
- Automatically install the Site24x7 agent.
- Configure and enable the MongoDB plugin.
- Start monitoring without any manual setup.
This enables seamless monitoring even when instances are scaled up or replaced automatically.