Skip to content

Commit

Permalink
prometheus data source working
Browse files Browse the repository at this point in the history
  • Loading branch information
GilHoggarth committed Nov 24, 2023
1 parent c739093 commit 0ad8f8c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ monitor/grafana/provisioning/dashboards/wa_status.json
# aws generated content
monitor/aws/alertmanager/config.yml
monitor/aws/grafana/grafana.ini
monitor/aws/grafana/provisioning/dashboards/blukwa.yaml
monitor/aws/grafana/provisioning/datasources/frequent_crawl.yaml
monitor/aws/grafana/provisioning/datasources/prometheus.yaml
monitor/aws/prometheus/prometheus.yml
Expand Down
9 changes: 6 additions & 3 deletions monitor/aws/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- "${PROMETHEUS_DATA}:/prometheus"
extra_hosts:
- 'fc:172.31.43.254'
- 'monitor:172.31.18.188'
- "monitor:${SERVER_IP}"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
Expand All @@ -44,11 +44,14 @@ services:
depends_on:
- prometheus
user: "1000"
extra_hosts:
- 'fc:172.31.43.254'
- "monitor:${SERVER_IP}"
environment:
- "GF_AUTH_ANONYMOUS_ENABLED=true"
- GF_AUTH_ANONYMOUS_ORG_NAME=${GRAFANA_ORG_NAME}
- "GF_AUTH_ANONYMOUS_ORG_NAME=${GRAFANA_ORG_NAME}"
- "GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer"
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- "GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}"
volumes:
- ./grafana:/etc/grafana
- "${GRAFANA_DATA}:/var/lib/grafana"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: 1

providers:
- name: 'BLUKWA'
- name: ${GRAFANA_ORG_NAME}
orgId: 1
folder: ''
type: file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ apiVersion: 1

datasources:
- name: 'FC AWS Embedded Prometheus'
type: prometheus
access: proxy
type: "prometheus"
access: "proxy"
orgId: 1
url: http://${FC_EMBEDDED_SERVICE_NAME}:9191
isDefault: false
url: "http://${FC_EMBEDDED_SERVICE_IP}:9191"
isDefault: "false"
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
access: direct
- name: "Prometheus"
type: "prometheus"
access: "proxy"
orgId: 1
url: http://${PROMETHEUS_SERVICE_NAME}
isDefault: true
url: "http://${SERVER_IP}:${PROMETHEUS_PORT}"
isDefault: "true"
6 changes: 3 additions & 3 deletions monitor/aws/prometheus/prometheus.yml-template
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets:
- 'monitor:9100'
- 'fc:9100'
- "${PROMETHEUS_SERVICE_NAME}:9100"
- "${FC_PROMETHEUS_SERVICE_NAME}:9100"

- job_name: 'federate'
scrape_interval: 20s
Expand All @@ -39,4 +39,4 @@ scrape_configs:
- '{job="kafka"}'
static_configs:
- targets:
- 'fc:9191'
- "${FC_PROMETHEUS_SERVICE_NAME}:9191"
10 changes: 9 additions & 1 deletion monitor/aws/start_monitor.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/env bash
set -o nounset
export SERVER_IP=$(nmcli c s System\ eth0 | grep IP4.ADDRESS | awk '{print $2}' | awk -F '/' '{print $1}')


# source monitor settings or exit
Expand All @@ -10,6 +11,10 @@ else
echo -e "ERROR: Monitor settings [${SETTINGS}] missing"
exit 1
fi
if [[ "${GRAFANA_ADMIN_PASSWORD}" == "" ]]; then
echo -e "ERROR: GRAFANA_ADMIN_PASSWORD missing"
exit 1
fi


# common
Expand All @@ -27,6 +32,7 @@ STORAGE_PATH=/mnt/data/monitor

# prometheus
export PROMETHEUS_SERVICE_NAME='monitor'
export FC_PROMETHEUS_SERVICE_NAME='fc'
export PROMETHEUS_DATA=${STORAGE_PATH}/prometheus
export PROMETHEUS_PORT=9090
[[ -d ${PROMETHEUS_DATA}/ ]] || mkdir -p ${PROMETHEUS_DATA}
Expand All @@ -38,10 +44,12 @@ envsubst < ./prometheus/prometheus.yml-template > ./prometheus/prometheus.yml
export GRAFANA_SERVICE_NAME='monitor'
export GRAFANA_PORT=3000
export GRAFANA_DATA=${STORAGE_PATH}/grafana
export FC_EMBEDDED_SERVICE_NAME='172.31.43.254'
export FC_EMBEDDED_SERVICE_IP='172.31.43.254'
export GRAFANA_ORG_NAME='blukwa'
[[ -d ${GRAFANA_DATA}/ ]] || mkdir -p ${GRAFANA_DATA}
chown -R ${USER}:${USER} ${GRAFANA_DATA}
envsubst < ./grafana/grafana.ini-template > ./grafana/grafana.ini
envsubst < ./grafana/provisioning/dashboards/blukwa.yaml-template > ./grafana/provisioning/dashboards/blukwa.yaml
envsubst < ./grafana/provisioning/datasources/prometheus.yaml-template > ./grafana/provisioning/datasources/prometheus.yaml
envsubst < ./grafana/provisioning/datasources/frequent_crawl.yaml-template > ./grafana/provisioning/datasources/frequent_crawl.yaml

Expand Down

0 comments on commit 0ad8f8c

Please sign in to comment.