Add observability platform Ansible project
Deploys the Grafana stack (Prometheus/Alertmanager/Loki/Tempo/Grafana with Alloy as collector) and the ELK stack (Filebeat/Logstash/Elasticsearch/ Kibana) via Docker Compose on a target host. External to the application repo, pre-built by the mentor.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
filebeat.inputs:
|
||||
- type: filestream
|
||||
id: docker-containers
|
||||
enabled: true
|
||||
paths:
|
||||
- /var/lib/docker/containers/*/*.log
|
||||
parsers:
|
||||
- container:
|
||||
stream: all
|
||||
format: docker
|
||||
|
||||
processors:
|
||||
- add_docker_metadata:
|
||||
host: unix:///var/run/docker.sock
|
||||
- add_host_metadata: ~
|
||||
|
||||
output.logstash:
|
||||
hosts: ["logstash:5044"]
|
||||
|
||||
logging.level: info
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Elasticsearch
|
||||
uid: elasticsearch
|
||||
type: elasticsearch
|
||||
access: proxy
|
||||
url: http://elasticsearch:9200
|
||||
database: "logs-*"
|
||||
isDefault: true
|
||||
editable: true
|
||||
jsonData:
|
||||
index: "logs-*"
|
||||
interval: Daily
|
||||
timeField: "@timestamp"
|
||||
logMessageField: message
|
||||
logLevelField: log.level
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
input {
|
||||
beats {
|
||||
port => 5044
|
||||
}
|
||||
tcp {
|
||||
port => 5000
|
||||
codec => json_lines
|
||||
}
|
||||
}
|
||||
|
||||
filter {
|
||||
if [message] =~ /^\s*\{/ {
|
||||
json {
|
||||
source => "message"
|
||||
skip_on_invalid_json => true
|
||||
}
|
||||
}
|
||||
mutate {
|
||||
add_field => { "[@metadata][target_index]" => "logs-%{+YYYY.MM.dd}" }
|
||||
}
|
||||
}
|
||||
|
||||
output {
|
||||
elasticsearch {
|
||||
hosts => ["http://elasticsearch:9200"]
|
||||
index => "%{[@metadata][target_index]}"
|
||||
}
|
||||
stdout { codec => dots }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
services:
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:{{ elastic_version }}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
discovery.type: single-node
|
||||
xpack.security.enabled: "false"
|
||||
xpack.security.enrollment.enabled: "false"
|
||||
ES_JAVA_OPTS: "-Xms{{ elasticsearch_heap }} -Xmx{{ elasticsearch_heap }}"
|
||||
volumes:
|
||||
- elasticsearch-data:/usr/share/elasticsearch/data
|
||||
ports:
|
||||
- "9200:9200"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -fsS http://localhost:9200/_cluster/health || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
networks: [observability]
|
||||
|
||||
logstash:
|
||||
image: docker.elastic.co/logstash/logstash:{{ elastic_version }}
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
elasticsearch:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./config/logstash/pipeline:/usr/share/logstash/pipeline:ro
|
||||
- logstash-data:/usr/share/logstash/data
|
||||
ports:
|
||||
- "5044:5044"
|
||||
- "5000:5000/tcp"
|
||||
networks: [observability]
|
||||
|
||||
filebeat:
|
||||
image: docker.elastic.co/beats/filebeat:{{ elastic_version }}
|
||||
user: root
|
||||
restart: unless-stopped
|
||||
command: ["filebeat", "-e", "--strict.perms=false"]
|
||||
depends_on: [logstash]
|
||||
volumes:
|
||||
- ./config/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
|
||||
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- filebeat-data:/usr/share/filebeat/data
|
||||
networks: [observability]
|
||||
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:{{ elastic_version }}
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
elasticsearch:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
|
||||
ports:
|
||||
- "5601:5601"
|
||||
networks: [observability]
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:{{ grafana_version }}
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
elasticsearch:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: "{{ grafana_admin_user }}"
|
||||
GF_SECURITY_ADMIN_PASSWORD: "{{ grafana_admin_password }}"
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
volumes:
|
||||
- grafana-data:/var/lib/grafana
|
||||
- ./config/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
ports:
|
||||
- "3000:3000"
|
||||
networks: [observability]
|
||||
|
||||
volumes:
|
||||
elasticsearch-data:
|
||||
logstash-data:
|
||||
filebeat-data:
|
||||
grafana-data:
|
||||
|
||||
networks:
|
||||
observability:
|
||||
driver: bridge
|
||||
|
||||
Reference in New Issue
Block a user