Skip to content

Commit

Permalink
novos comandos e gerador de metricas
Browse files Browse the repository at this point in the history
  • Loading branch information
themarcelor committed Sep 8, 2024
1 parent e7b9baa commit a92c48b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions comandos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ docker run --rm -d --name prometheus -p 9090:9090 --network sre-test-network -v

docker run --rm -d --name=collector -p 4317:4317 -p 9464:9464 -p 55680:55680 -p 55681:55681 -v $(PWD)/collector-config.yaml:/conf/collector-config.yaml --network sre-test-network otel/opentelemetry-collector:latest --config /conf/collector-config.yaml

docker run --rm -it --name prometheus -p 9090:9090 --network sre-test-network -v $(PWD)/prometheus.yml:/etc/prometheus/prometheus.yml --entrypoint sh prom/prometheus
promtool tsdb create-blocks-from openmetrics metricas
/bin/prometheus --config.file=/etc/prometheus/prometheus.yml

docker run --rm -it --name recebedor-de-alertas -p "8080:8080" --network sre-test-network daime/http-dump:latest
29 changes: 29 additions & 0 deletions gerador-de-datapoints-historicos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

cat << EOF
# HELP http_requests_total The total number of HTTP requests.
# TYPE http_requests_total counter
EOF

# Data/Hora atual
AGORA=$(date +"%s")
# Numero de datapoints historicos
NUMERO_DE_MINUTOS=60
# As metricas vao comecar a surgir aqui
PONTO_DE_PARTIDA=$(($AGORA - ($NUMERO_DE_MINUTOS * 60)))

NUMERO_DE_ERROS=0
MINUTO_EM_QUE_ERROS_COMECAM_A_OCORRER=10

for i in $( seq 1 $NUMERO_DE_MINUTOS )
do
PROXIMA_DATA=$(($PONTO_DE_PARTIDA + ($i * 60)))
echo "http_requests_total{code=\"200\",service=\"servicoX\"} 1000 $PROXIMA_DATA"
echo "http_requests_total{code=\"500\",service=\"servicoX\"} $NUMERO_DE_ERROS $PROXIMA_DATA"
if [[ $i -ge $MINUTO_EM_QUE_ERROS_COMECAM_A_OCORRER ]]; then
# Entramos na janela de erros, vamos incrementar o num de erros a cada minuto
NUMERO_DE_ERROS=$((NUMERO_DE_ERROS+1))
fi
done

echo "# EOF"

0 comments on commit a92c48b

Please sign in to comment.