Skip to content

Commit

Permalink
feat: change grafana to victoriametrics in local setup (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
pboros authored Oct 4, 2022
1 parent c3ab704 commit d95a431
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local_run: server
run_full:
${DOCKER_COMPOSE} up --build --detach tigris_grafana
./${DOCKER_DIR}/grafana/set_admin_password.sh
./${DOCKER_DIR}/grafana/add_prometheus_datasource.sh
./${DOCKER_DIR}/grafana/add_victoriametrics_datasource.sh

bins: $(BINS)

Expand Down
27 changes: 20 additions & 7 deletions test/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,36 @@ services:
depends_on:
- tigris_server2

tigris_prometheus:
container_name: tigris_prometheus
image: prom/prometheus
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
tigris_victoriametrics:
container_name: tigris_victoriametrics
image: victoriametrics/victoria-metrics
ports:
- "9090:9090"
- "8428:8428"
depends_on:
- tigris_server

tigris_vmagent:
container_name: tigris_vmagent
image: victoriametrics/vmagent
ports:
- "8429:8429"
volumes:
- ./victoriametrics/vmagent.yml:/etc/victoriametrics/vmagent.yml
command:
- "-promscrape.config=/etc/victoriametrics/vmagent.yml"
- "-promscrape.config.strictParse=false"
- "-remoteWrite.url=http://tigris_victoriametrics:8428/api/v1/write"
depends_on:
- tigris_victoriametrics

tigris_grafana:
container_name: tigris_grafana
image: grafana/grafana
ports:
- "3000:3000"
depends_on:
- tigris_prometheus
- tigris_victoriametrics
- tigris_vmagent
- tigris_server

volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,32 @@ if [ -z "${GRAFANA_URL}" ]; then
GRAFANA_URL="http://localhost:3000"
fi

if [ -z "${PROMETHEUS_URL}" ]; then
PROMETHEUS_URL="http://tigris_prometheus:9090"
if [ -z "${VICROTIAMETRICS_URL}" ]; then
VICROTIAMETRICS_URL="http://tigris_victoriametrics:8428"
fi

function add_prometheus {
function add_victoriametrics {
curl -s \
-u admin:"${GRAFANA_PASSWORD}" \
"${GRAFANA_URL}/api/datasources" \
-X POST \
--data "{\"name\": \"tigris_prometheus\", \"type\": \"prometheus\", \"url\": \"${PROMETHEUS_URL}\", \"access\": \"proxy\"}" \
--data "{\"name\": \"tigris_victoriametrics\",
\"type\": \"prometheus\",
\"url\": \"${VICROTIAMETRICS_URL}\",
\"access\": \"proxy\"}" \
--header 'content-type: application/json'
}

max_tries=20
for i in $(seq 1 ${max_tries}); do
if add_prometheus; then
if add_victoriametrics; then
echo
echo "Successfully added prometheus data source"
echo "Successfully added victoriametrics data source"
echo "Grafana available at: $GRAFANA_URL"
echo "Prometheus available at: http://localhost:9090"
echo "Victoriametrics available at: http://localhost:8428"
break
else
echo "Adding prometheus was not successful, retrying soon. Iteration: $i"
echo "Adding victoriametrics was not successful, retrying soon. Iteration: $i"
sleep 0.5
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ global:
evaluation_interval: 5s # Default is 1m, suitable for development

scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['prometheus:8000']

- job_name: 'tigris_server'
scrape_interval: 5s
static_configs:
- targets: ['tigris_server:8081']
metric_relabel_configs:
- source_labels: [__name__]
target_label: __name__
replacement: tigris_$1

0 comments on commit d95a431

Please sign in to comment.