3
respostas

Métricas Logged Users e Auth Errors - Metrics broser não exibe auth_user_success_total

Oi, estou com problemas no módulo 002 - Aula 01 Métricas Logged Users e Auth Errors.

Aos 25segundos de aula, o professor fala sobre a métrica auth_user_success_total Porém ao digitar ela o Metrics Browser não encontra ela. Colocando apenas "user", também não acha nada relacionado.

O que pode estar ocorrendo?

3 respostas

Notei que ao tentar acessar via http://localhost:8080/topicos/1 http://localhost:8080/topicos/

No navegador surgem os erros:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Dec 20 13:32:43 BRT 2022
There was an unexpected error (type=Internal Server Error, status=500).

E na console do terminal, onde foi subida a aplicação via start.sh, surgem os erros:


2022-12-20 13:53:09.092  WARN 66193 --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 08S01
2022-12-20 13:53:09.092 ERROR 66193 --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper   : Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2022-12-20 13:53:09.094 ERROR 66193 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause

2022-12-20 14:00:31.795  WARN 66193 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 08S01
2022-12-20 14:00:31.795 ERROR 66193 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2022-12-20 14:00:31.798 ERROR 66193 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause

RESOLVIDO.

Meu container do app estava com status (health: starting):

fernando@debian10x64:~$ docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS                             PORTS                               NAMES
83e10d4ed708   prom/prometheus:latest   "/bin/prometheus --c…"   36 seconds ago   Restarting (2) 1 second ago                                            prometheus-forum-api
ee9f972a9709   client-forum-api         "/scripts/client.sh"     36 seconds ago   Up 35 seconds                                                          client-forum-api
64fdc02e7306   nginx                    "/docker-entrypoint.…"   37 seconds ago   Up 36 seconds                      0.0.0.0:80->80/tcp, :::80->80/tcp   proxy-forum-api
2aa62dd5f35b   app-forum-api            "java -Xms128M -Xmx1…"   38 seconds ago   Up 37 seconds (health: starting)                                       app-forum-api
05941ffc7974   mysql:5.7                "docker-entrypoint.s…"   39 seconds ago   Up 37 seconds                                                          mysql-forum-api
2c025f59b117   redis                    "docker-entrypoint.s…"   41 seconds ago   Up 40 seconds                                                          redis-forum-api
fernando@debian10x64:~$

E eu tinha aqueles problemas para acessar os endpoints da API de tópicos. Problema de não conseguir acessar os endpoints da API foi resolvido. Eu estava tentando acessar eles usando a porta 8080, que é usada na parte inicial do curso, quando a aplicação é iniciada via script, ainda não tem um Container. Como estou na fase onde a aplicação já tem um Container, verifiquei que esse container usa a porta 80 ao invés da 8080, então só ajustei a porta e consegui acessar os endpoints da minha API de tópicos.

Endpoints OK:


fernando@debian10x64:~$ curl -v http://192.168.92.129:80/topicos
* Expire in 0 ms for 6 (transfer 0x55fc12415fb0)
*   Trying 192.168.92.129...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55fc12415fb0)
* Connected to 192.168.92.129 (192.168.92.129) port 80 (#0)
> GET /topicos HTTP/1.1
> Host: 192.168.92.129
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200
< Server: nginx
< Date: Sun, 25 Dec 2022 17:04:40 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
<
* Connection #0 to host 192.168.92.129 left intact
{"content":[{"id":3,"titulo":"Duvida 3","mensagem":"Tag HTML","dataCriacao":"2019-05-05T20:00:00"},{"id":2,"titulo":"Duvida 2","mensagem":"Projeto nao compila","dataCriacao":"2019-05-05T19:00:00"},{"id":1,"titulo":"Duvida 1","mensagem":"Erro ao criar projeto","dataCriacao":"2019-05-05T18:00:00"}],"pageable":{"sort":{"unsorted":false,"sorted":true,"empty":false},"pageNumber":0,"pageSize":10,"offset":0,"paged":true,"unpaged":false},"last":true,"totalPages":1,"totalElements":3,"sort":{"unsorted":false,"sorted":true,"empty":false},"first":true,"numberOfElements":3,"size":10,"number":0,"empty":false}fernando@debian10x64:~$ curl -v http://192.168.92.129:80/topicos/1
* Expire in 0 ms for 6 (transfer 0x562e76100fb0)
*   Trying 192.168.92.129...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x562e76100fb0)
* Connected to 192.168.92.129 (192.168.92.129) port 80 (#0)
> GET /topicos/1 HTTP/1.1
> Host: 192.168.92.129
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200
< Server: nginx
< Date: Sun, 25 Dec 2022 17:04:40 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
<
* Connection #0 to host 192.168.92.129 left intact
{"id":1,"titulo":"Duvida 1","mensagem":"Erro ao criar projeto","dataCriacao":"2019-05-05T18:00:00","nomeAutor":"Aluno","status":"NAO_RESPONDIDO","respostas":[]}fernando@debian10x64:~$
fernando@debian10x64:~$
fernando@debian10x64:~$

Sobre a métrica "auth_user_success_total" que eu não encontrava no Grafana: agora que consegui resolver os problemas com os Endpoints da API, acessei eles algumas vezes, consequentemente, gerou métricas de "auth_user_success_total" no meu endpoint de métricas: http://192.168.92.129/metrics

Fui verificar no Grafana, quando adiciono um panel e tento buscar pela métrica "auth_user_success_total" no Metrics Browser, agora consigo encontrar ela! Tudo certo.

Opa, Fernando. Tudo bem?

Que bom que conseguiu detectar o problema e solucionar.

Bons estudos!