-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
90 lines (74 loc) · 4.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
VAR_FILE=variables.env
include $(VAR_FILE)
.SILENT:
.PHONY: help
# Based on https://gist.github.com/prwhite/8168133#comment-1313022
## This help screen
help:
printf "Available targets\n\n"
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "%-30s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Start all components
start:
@echo "-- Start all components --"
docker-compose up -d
## Stop all components
stop:
@echo "-- Stop all components --"
@docker-compose down
## Start all components using ECR images to prevent docker pull quota limits
start-ecr:
@echo "-- Start all components --"
docker-compose -f ecr.docker-compose.yml up -d
timeout 1m ./grafana_healthcheck.sh || echo Grafana startup timed out
stop-ecr:
@echo "-- Start all components --"
docker-compose -f ecr.docker-compose.yml down
## Create datasources (proxy) in grafana and load Dashboards (grafana-create-source-proxy grafana-load-dashboards)
init: grafana-create-source-proxy grafana-load-dashboards
## Create datasource in proxy mode in Grafana
grafana-create-source-proxy:
@echo "-- Create Datasource in Grafana 1/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"influxdb","type":"influxdb","url":"http://influxdb:8086","access":"proxy","isDefault":false,"database":"aos"}'
@echo "\n-- Create Datasource in Grafana 2/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"prometheus","type":"prometheus","url":"http://prometheus:9090","access":"proxy","isDefault":true}'
## Create datasource in direct mode in Grafana (use that is grafana cannot access the data)
grafana-create-source-direct:
@echo "-- Cleanup Datasources in Grafana"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources/1' -X DELETE -H 'Content-Type: application/json' -H 'Accept: application/json'
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources/2' -X DELETE -H 'Content-Type: application/json' -H 'Accept: application/json'
@echo "\n-- Create Datasource in Grafana 1/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"influxdb","type":"influxdb","url":"http://$(LOCAL_IP):8086","access":"direct","isDefault":false,"database":"aos"}'
@echo "\n-- Create Datasource in Grafana 2/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"prometheus","type":"prometheus","url":"http://$(LOCAL_IP):9090","access":"direct","isDefault":true}'
## Load/Reload the Dashboards in Grafana
grafana-load-dashboards:
@echo "-- Load Dashboard in Grafana 1/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/dashboards/db' -X POST -H "Content-Type: application/json" --data-binary @dashboards/apstra_aos_blueprint.json
@echo "\n-- Load Dashboard in Grafana 2/2"
@curl 'http://$(GRAFANA_LOGIN):$(GRAFANA_PASSWORD)@localhost:3000/api/dashboards/db' -X POST -H "Content-Type: application/json" --data-binary @dashboards/apstra_aos_device.json
## Stop all components, Update all images, Restart all components, Reload the Dashboards (stop update-docker start grafana-load-dashboards)
update: stop update-docker start grafana-load-dashboards
## Update Docker Images
update-docker:
@echo "-- Download Latest Images from Docker Hub --"
@docker-compose pull --ignore-pull-failures
## Delete Grafana information and delete current streaming session on AOS (clean-docker clean-aos)
clean: clean-docker # clean-aos
## Delete Grafana information
clean-docker:
@echo "-- Delete all Data in Grafana (Grafana must be stopped) --"
docker volume rm -f aosomstreaming_grafana_data_2
#
# ## Delete current streaming session on AOS
# clean-aos:
# @export $(shell cat variables.env | xargs)
# @echo "Delete all streaming session on the server (AOS server must be reacheable)"
# ansible-playbook -i tools/hosts.ini tools/pb.streaming_delete.yaml