Skip to content

Commit

Permalink
uf
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamv108 committed Sep 5, 2023
1 parent 8e48ba6 commit 3b3a97f
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 6 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := /bin/bash
OS := $(shell uname)

define start-services
@docker-compose -f compose.yaml up --force-recreate -d --remove-orphans fluentbit mysql kafka kafdrop elasticsearch
@docker-compose -f compose.yaml up --force-recreate -d --remove-orphans fluentbit mysql kafka kafdrop elasticsearch prometheus grafana telegraf influxdb
endef

define start-app
Expand Down Expand Up @@ -34,6 +34,11 @@ define k8s-delete-app
@kubectl delete -f ./k8s/app.yaml
endef

define del-local-app
@docker stop server-sent-events
@docker rm server-sent-events
endef

.PHONY: help install setup teardown

help:
Expand Down Expand Up @@ -106,5 +111,10 @@ k8s-apply:
k8s-delete-app:
$(call k8s-delete-app)

del-local-app:
$(call del-local-app)

local-app: build
$(call local-app)
$(call local-app)

local-app-re: del-local-app local-app
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ dependencies {
'org.projectlombok:lombok',
)
developmentOnly (
'org.springframework.boot:spring-boot-devtools',
'org.springframework.boot:spring-boot-devtools',
)
implementation(
'org.springframework.boot:spring-boot-starter-data-jpa',
'org.springframework.boot:spring-boot-starter-webflux',
'org.springframework.boot:spring-boot-starter-log4j2',
'com.lmax:disruptor:3.3.6',
'org.springframework.kafka:spring-kafka',
'com.google.code.gson:gson:2.7',
'com.google.code.gson:gson:2.8.9',
'org.springframework.boot:spring-boot-starter-actuator',
)
runtimeOnly (
'com.mysql:mysql-connector-j'
'com.mysql:mysql-connector-j',
'io.micrometer:micrometer-registry-prometheus',
)
testImplementation (
'org.springframework.boot:spring-boot-starter-test',
Expand Down
59 changes: 59 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
- mysql
- kafka
- elasticsearch
- prometheus

logging:
driver: fluentd
Expand Down Expand Up @@ -104,6 +105,64 @@ services:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.type=single-node

prometheus:
image: prom/prometheus:v2.44.0
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml

grafana:
image: grafana/grafana
container_name: grafana-server
restart: always
depends_on:
- prometheus
- influxdb
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_INSTALL_PLUGINS=
links:
- influxdb
ports:
- '3000:3000'
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources

telegraf:
image: telegraf
container_name: telegraf
restart: always
volumes:
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
depends_on:
- influxdb
- elasticsearch
links:
- influxdb
ports:
- '8125:8125'

influxdb:
image: influxdb:1.8-alpine
container_name: influxdb
restart: always
environment:
- INFLUXDB_DB=influx
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=admin
ports:
- '8086:8086'
volumes:
- influxdb_data:/var/lib/influxdb

volumes:
grafana_data: { }
influxdb_data: { }

networks:
sse:
external: true
7 changes: 7 additions & 0 deletions grafana/provisioning/datasources/datasources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
2 changes: 1 addition & 1 deletion k8s/kafdrop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ spec:
name: kafdrop
protocol: TCP
selector:
app: kafka #name of deployed kafka service
app: kafka
type: LoadBalancer
8 changes: 8 additions & 0 deletions prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
scrape_configs:
- job_name: 'MyAppMetrics'
metrics_path: '/actuator/prometheus'
scrape_interval: 3s
static_configs:
- targets: ['host.docker.internal:8080']
labels:
application: 'My Spring Boot Application'
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ spring.kafka.bootstrap-servers=localhost:29092
kafka.group.id=server-sent-events
kafka.topic.name=userevents
spring.kafka.consumer.auto-offset-reset=earliest

# Metrics/Actuator
management.endpoints.web.exposure.include=*
35 changes: 35 additions & 0 deletions telegraf/telegraf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[global_tags]

[agent]
interval = "60s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = "192.xxx.0.xxx"
omit_hostname = false

[[outputs.influxdb]]
urls = ["http://influxdb:8086"]
database = "influx"
timeout = "5s"
username = "telegraf"
password = "metricsmetricsmetricsmetrics"


[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false


[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.mem]]

[[inputs.processes]]

0 comments on commit 3b3a97f

Please sign in to comment.