Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add config promtail for aws ec2 #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions helpers/aws/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Prometheus on EC2 & ECS:
# Config **domolo** for AWS

## Prometheus on **EC2 & ECS**

Some helpers for anyone configuring Prometheus on ECS and AWS EC2.

To get started on AWS ECS and EC2:
To get started on **AWS ECS** and **EC2**:

*For EC2/ECS nodes*:
- Import the ecs task definition and add cadvisor and node-exporter service/task definition and run them on each host you want to be monitored
Expand All @@ -11,7 +13,7 @@ To get started on AWS ECS and EC2:

*For Prometheus host*:

- Copy prometheus.yml configuration present here to base prometheus configuration to enable EC2 service discovery
- Copy `prometheus.yml` configuration present here to base `prometheus` configuration to enable EC2 service discovery
- `docker compose up -d`

**Note**:
Expand All @@ -20,3 +22,16 @@ Set query.staleness-delta to 1m make metrics more realtime

### TODO
- Add alerting rules based on ECS


## Promtail for **EC2**

To get started on **AWS EC2**:

*For EC2 nodes*:

- Copy `promtail-ec2.yaml` configuration present here to base `promtail` configuration to enable EC2 service discovery
- `docker compose up -d`
- More [docs](https://grafana.com/blog/2020/07/13/loki-tutorial-how-to-set-up-promtail-on-aws-ec2-to-find-and-analyze-your-logs/)

### TODO
32 changes: 32 additions & 0 deletions helpers/aws/promtail-ec2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
server:
http_listen_port: 3100
grpc_listen_port: 0

clients:
- url: https://<user id>:<api secret>@logs-prod-us-central1.grafana.net/loki/api/v1/push

positions:
filename: /opt/promtail/positions.yaml

scrape_configs:
- job_name: ec2-logs
ec2_sd_configs:
- region: us-east-2
access_key: REDACTED
secret_key: REDACTED
relabel_configs:
- source_labels: [__meta_ec2_tag_Name]
target_label: name
action: replace
- source_labels: [__meta_ec2_instance_id]
target_label: instance
action: replace
- source_labels: [__meta_ec2_availability_zone]
target_label: zone
action: replace
- action: replace
replacement: /var/log/**.log
target_label: __path__
- source_labels: [__meta_ec2_private_dns_name]
regex: "(.*)"
target_label: __host__