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

Integrated grafana and prometheus prod profile #156

Merged
merged 3 commits into from
Apr 18, 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
74 changes: 64 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,59 @@ jobs:
platforms: linux/arm64
env:
LOGSTASH_INTERNAL_PASSWORD: ${{ secrets.LOGSTASH_INTERNAL_PASSWORD }}


docker-push-grafana:
name: Push grafana service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ e2e-tests ]
steps:
- name: Set up Docker Buildx # required for building multi-platform images
uses: docker/setup-buildx-action@v1

- name: Check out the repo
uses: actions/checkout@v4

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es05b/grafana
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: monitoring/grafana
platforms: linux/arm64
env:
GF_SECURITY_ADMIN_USER: ${{ secrets.GF_SECURITY_ADMIN_USER }}
GF_SECURITY_ADMIN_PASSWORD: ${{ secrets.GF_SECURITY_ADMIN_PASSWORD }}
GF_SERVER_SERVE_FROM_SUB_PATH: false

docker-push-prometheus:
name: Push prometheus service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ e2e-tests ]
steps:
- name: Set up Docker Buildx # required for building multi-platform images
uses: docker/setup-buildx-action@v1

- name: Check out the repo
uses: actions/checkout@v4

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es05b/prometheus
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: monitoring/prometheus
platforms: linux/arm64

deploy:
name: Deploy over SSH
runs-on: self-hosted
Expand All @@ -378,6 +430,8 @@ jobs:
- docker-push-elasticsearch
- docker-push-kibana
- docker-push-logstash
- docker-push-grafana
- docker-push-prometheus
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand All @@ -387,12 +441,12 @@ jobs:
key: ${{ secrets.DEPLOY_KEY }}

command: |
mkdir -p wiq_es05b
cd wiq_es05b
rm -rf ./*
wget https://raw.githubusercontent.com/arquisoft/wiq_es05b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es05b/master/.env -O .env
docker logout ghcr.io
docker logout ghcr
docker image prune -f
docker compose --profile prod up -d --pull always
mkdir -p wiq_es05b
cd wiq_es05b
rm -rf ./*
wget https://raw.githubusercontent.com/arquisoft/wiq_es05b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es05b/master/.env -O .env
docker logout ghcr.io
docker logout ghcr
docker image prune -f
docker compose --profile prod up -d --pull always
23 changes: 12 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ services:
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-changeme}
LOGSTASH_INTERNAL_PASSWORD: ${LOGSTASH_INTERNAL_PASSWORD:-changeme}
KIBANA_SYSTEM_PASSWORD: ${KIBANA_SYSTEM_PASSWORD:-changeme}
CUSTOM_USER: ${CUSTOM_USER:-user}
CUSTOM_USER_PASSWORD: ${CUSTOM_USER_PASSWORD:-changeme}
networks:
- mynetwork

Expand Down Expand Up @@ -199,33 +197,36 @@ services:
# Development services

prometheus:
image: prom/prometheus
image: ghcr.io/arquisoft/wiq_es05b/prometheus:latest
container_name: prometheus-${teamname:-wiq_es05b}
profiles: ["dev"]
build: ./monitoring/prometheus
profiles: ["dev", "prod"]
networks:
- mynetwork
volumes:
- ./gatewayservice/monitoring/prometheus:/etc/prometheus
- prometheus_data:/prometheus
ports:
- "9090:9090"
depends_on:
- gatewayservice

grafana:
image: grafana/grafana
image: ghcr.io/arquisoft/wiq_es05b/grafana:latest
container_name: grafana-${teamname:-wiq_es05b}
profiles: ["dev"]
build: ./monitoring/grafana
profiles: ["dev", "prod"]
networks:
- mynetwork
volumes:
- grafana_data:/var/lib/grafana
- ./gatewayservice/monitoring/grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SERVER_HTTP_PORT=9091
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
# - GF_AUTH_DISABLE_LOGIN_FORM=true
# - GF_AUTH_ANONYMOUS_ENABLED=true
# - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD:-changeme}
- GF_SERVER_SERVE_FROM_SUB_PATH=${GF_SERVER_SERVE_FROM_SUB_PATH:-true}
ports:
- "9091:9091"
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion gatewayservice/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ output.logstash:
mem:
events: 4096
flush.min_events: 2048
flush.timeout: 60s
flush.timeout: 15s

# ================================= Processors =================================
processors:
Expand Down
1 change: 0 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const logger = winston.createLogger({
const app = express();
const port = 8000;

app.use(cors());
app.use(express.json());

app.use(require("./middleware/ReqLoggerMiddleware")(logger.info.bind(logger)))
Expand Down
6 changes: 0 additions & 6 deletions gatewayservice/monitoring/prometheus/prometheus.yml

This file was deleted.

2 changes: 1 addition & 1 deletion jordi/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ output.logstash:
mem:
events: 4096
flush.min_events: 2048
flush.timeout: 60s
flush.timeout: 15s

# ================================= Processors =================================
processors:
Expand Down
5 changes: 5 additions & 0 deletions jordi/jordi-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const mongoose = require('mongoose');
const cron = require('node-cron');
const winston = require('winston');
const ecsFormat = require('@elastic/ecs-winston-format');
const promBundle = require('express-prom-bundle');

const WikidataQAManager = require('./WikidataGenerator');
const groups = require('./groups.json');
Expand Down Expand Up @@ -41,6 +42,10 @@ app.use(express.json());
app.use(require("./middleware/ReqLoggerMiddleware")(logger.info.bind(logger)))
app.use(require("./middleware/ResLoggerMiddleware")(logger.info.bind(logger)))

//Prometheus configuration
const metricsMiddleware = promBundle({includeMethod: true});
app.use(metricsMiddleware);

// Routes
require("./routes/routes")(app, questionsRepository);

Expand Down
Loading