This pipeline via automation will deploy Prometheus and Grafana on an AWS Fargate also the core infrastructure to support it.
Grafana - Grafana is a multi-platform open source analytics and interactive visualization web application.
Prometheus - Prometheus is a free software application used for event monitoring and alerting.
The below diagram shows the AWS resources.
- These tools were installed:
- Update the file
group_vars/all/common.yml
accordingly.
---
cloudformation:
check_mode_override: false
region: ap-southeast-2
create_changeset: true
state: present
Route53:
HostedZoneName: "ugulino.com."
RecordName: "monitor.ugulino.com"
CertificateId: "5eaa197e" # your ACM Id
The file deploy-role.yml
will deploy each role required to deploy this project.
---
- hosts: localhost
roles:
- vpc-baseline
- ecs-cluster
- ecs-monitor
- route53
The below command will execute the tasks defined on the above file.
ansible-playbook deploy-role.yml -vvv
Output
You can verify the deployment via ansible output or via AWS CloudFormation console.
- Ansible Output:
- AWS CloudFormation Console:
An 'A' record was created pointing to Application Load Balancer via automation.
You can access and setup Grafana accessing the URL https://monitor.ugulino.com (be aware that this is my domain, probably you've setup a different one)
Default username and password is admin
Setup the Data Source for prometheus.
EC2 REQUIREMENTS:
- The EC2 instances taged as below
- The application node-exporter installed on the EC2.
- Allow Inbound and Outbound port 9100.
Grafana Dashboard Id 1860
The below prometheus.yml
was used for this environment. Upload this file to AWS EFS.
################-----//-----################
# USE THIS FILE AS AN EXAMPLE.
################-----//-----################
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: "ec2-nodes"
ec2_sd_configs:
- region: ap-southeast-2
port: 9100
relabel_configs:
- source_labels: [__meta_ec2_tag_prometheus]
regex: true.*
action: keep
- source_labels: [__meta_ec2_tag_Name]
target_label: instance
Basically, to destroy this deployment you can either do it via ansible command or AWS CloudFormation.
Change the file group_vars/all/common.yml
cloudformation:
check_mode_override: false
region: ap-southeast-2
create_changeset: true
state: absent # this is the value you need to change to destroy the stacks
Execute the command:
ansible-playbook deploy-role.yml -vvv
Select the CloudFormation stack, click delete, and then Delete stack.