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

Add grafana and prometheus #200

Merged
merged 4 commits into from
Apr 17, 2024
Merged
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
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MYSQL_HOST=db
KEYSTORE_PATH=./testCert.p12
KEYSTORE_PASSWORD=123456
WIQ_IMAGE=pelayori/wiq_es04b
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
script: |
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/docker-compose.yml -O docker-compose.yml
docker-compose down
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/prometheus.yml -O prometheus.yml
docker compose pull
docker-compose up -d
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Build stage with Maven and JDK 17
FROM maven:3.8.4-openjdk-17-slim as build
WORKDIR /app
WORKDIR ./app
COPY pom.xml .
COPY src src/
# Use Maven directly instead of the Maven Wrapper
RUN mvn clean package -DskipTests

# Run stage with JDK 17
FROM openjdk:17-slim
COPY --from=build /app/target/*.jar app.jar
COPY --from=build ./app/target/*.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=prod","-jar","/app.jar"]
EXPOSE 443
43 changes: 37 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ services:
restart: always

wiq_es04b:
image: ghcr.io/arquisoft/wiq_es04b:latest
image: ${WIQ_IMAGE:-ghcr.io/arquisoft/wiq_es04b:latest}
environment:
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_PORT: ${MYSQL_PORT}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE:-wiq_es04b}
MYSQL_USER: ${MYSQL_USER:-wiq_es04b}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-wiq_es04b}
MYSQL_PORT: ${MYSQL_PORT:-3306}
KEYSTORE_PATH: ${KEYSTORE_PATH}
KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD}
ports:
Expand All @@ -38,9 +38,40 @@ services:
volumes:
- ${KEYSTORE_PATH}:/certs/keystore.p12

prometheus:
image: prom/prometheus:latest
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
networks:
- mynetwork
depends_on:
- wiq_es04b
restart: always

grafana:
image: grafana/grafana:latest
volumes:
- grafana_data:/var/lib/grafana
environment:
GF_AUTH_DISABLE_LOGIN_FORM: 1
GF_AUTH_ANONYMOUS_ENABLED: true
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
ports:
- "3000:3000"
networks:
- mynetwork
depends_on:
- prometheus
restart: always

volumes:
db_data:
prometheus_data:
grafana_data:

networks:
mynetwork:
driver: bridge
driver: bridge
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
12 changes: 12 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
global:
scrape_interval: 2s
scrape_timeout: 1s

scrape_configs:
- job_name: 'spring-application'
scrape_interval: 2s
scrape_timeout: 1s
metrics_path: '/actuator/prometheus'
scheme: https
static_configs:
- targets: [ 'wikigame.es:443' ]
3 changes: 2 additions & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ spring.jpa.hibernate.ddl-auto=update
server.ssl.key-store=/certs/keystore.p12
server.ssl.key-store-password=${KEYSTORE_PASSWORD}
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=keystore
server.ssl.keyAlias=keystore
server.ssl.enabled-protocols=TLSv1.2
6 changes: 5 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Port 3000 for testing, local deployment
server.port=3000
server.port=3100
server.address=0.0.0.0

# HSQL db
Expand All @@ -13,3 +13,7 @@ springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/api
springdoc.swagger-ui.operationsSorter=method
springdoc.packagesToScan=com.uniovi.controllers.api

management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=prometheus
management.endpoints.jmx.exposure.include=*
55 changes: 55 additions & 0 deletions testCert.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Bag Attributes
friendlyName: youralias
localKeyID: 54 69 6D 65 20 31 37 31 33 32 38 34 33 38 34 39 32 35
subject=C = d, ST = d, L = d, O = d, OU = d, CN = d

issuer=C = d, ST = d, L = d, O = d, OU = d, CN = d

-----BEGIN CERTIFICATE-----
MIIDMzCCAhugAwIBAgIINBF3UUhqeiAwDQYJKoZIhvcNAQELBQAwSDEKMAgGA1UE
BhMBZDEKMAgGA1UECBMBZDEKMAgGA1UEBxMBZDEKMAgGA1UEChMBZDEKMAgGA1UE
CxMBZDEKMAgGA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= Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Unknown

issuer=C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Unknown

-----BEGIN CERTIFICATE-----
MIIDezCCAmOgAwIBAgIIXpBa0S6OUOUwDQYJKoZIhvcNAQELBQAwbDEQMA4GA1UE
BhMHVW5rbm93bjEQMA4GA1UECBMHVW5rbm93bjEQMA4GA1UEBxMHVW5rbm93bjEQ
MA4GA1UEChMHVW5rbm93bjEQMA4GA1UECxMHVW5rbm93bjEQMA4GA1UEAxMHVW5r
bm93bjAeFw0yNDA0MTYxNjQ2MjlaFw0zNDA0MTQxNjQ2MjlaMGwxEDAOBgNVBAYT
B1Vua25vd24xEDAOBgNVBAgTB1Vua25vd24xEDAOBgNVBAcTB1Vua25vd24xEDAO
BgNVBAoTB1Vua25vd24xEDAOBgNVBAsTB1Vua25vd24xEDAOBgNVBAMTB1Vua25v
d24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0bVkhX3R258hDQ0ce
iJNDVDdM0tHZaDXi6Z8/0a71C5/fNO/yDBGosL+DquRp0gDKpHQY0dd8+//Mr2mJ
gRqvQ5x6bs1PXkpdoCceHCWhV66nCdzGC6JAwxO4vlDAWA5dBZbyUGdLHnedq3vc
q6OYxg8HfMItU7nOME6cv7nb74FRgxkODWZ5xo96HkgAVmbutwn01+yZjtTPjug0
NO/nsciaHMpRKpCmopMsJ2fRJwOraT9CfGd3DLxgikHK1foJqtHmorBN5Nog3J2O
UtfhVYjsgU+PQXLP01mTMFFVxRbfWOySYfx3L/KNElbsHXLwVW4GcZwZV47Wmwj1
CEoNAgMBAAGjITAfMB0GA1UdDgQWBBS9q5bQ4tQ/xdvAHutrqAFLNOiLoDANBgkq
hkiG9w0BAQsFAAOCAQEAHGpap48KVmhZVBRhVtUOJQ7FUT5KoIdJ5SPgji5ofj9o
96NL9o4+/3hH7xSuVH4CDi/GRVt5nv0sXoKpZ1zXG2n/5E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