Giter Club home page Giter Club logo

full-cycle-2.0-prometheus's Introduction

full-cycle-2.0-prometheus

Files I produced during the "Observability / Prometheus" classes of my Microservices Full Cycle 3.0 course (pt-br).

First steps

docker-compose up  # Run all services

Prometheus

Access http://localhost:9090.

If you wanna see prometheus metrics of itself, access http://localhost:9090/metrics.

Example of a graph I created to track the number of requests prometheus made to its /metrics endpoint:

Prometheus graph example

Cadvisor

Access http://localhost:8080/metrics

Docker containers metrics of your machine from cadvisor

Cadvisor print

Grafana

Access http://localhost:3000

User: admin, Pass: admin

Import cadvisor dashboard, id: 14282

Cadvisor dashboard

Golang application

Enter inside the Golang application container

docker-compose exec app bash

Run these commands:

go get github.com/prometheus/client_golang/prometheus
go get github.com/prometheus/client_golang/prometheus/promhttp

go run main.go

Open another terminal outside the container and run:

for i in {1..20}; do curl localhost:8181; done  # Run curl 20 times
curl localhost:8181/metrics

The output should be similar to:

# HELP goapp_http_request_duration Duration in seconds of all HTTP requests
# TYPE goapp_http_request_duration histogram
goapp_http_request_duration_bucket{handler="Home",le="0.005"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.01"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.025"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.05"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.1"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.25"} 20
goapp_http_request_duration_bucket{handler="Home",le="0.5"} 20
goapp_http_request_duration_bucket{handler="Home",le="1"} 20
goapp_http_request_duration_bucket{handler="Home",le="2.5"} 20
goapp_http_request_duration_bucket{handler="Home",le="5"} 20
goapp_http_request_duration_bucket{handler="Home",le="10"} 20
goapp_http_request_duration_bucket{handler="Home",le="+Inf"} 20
goapp_http_request_duration_sum{handler="Home"} 0.00023509399999999996
goapp_http_request_duration_count{handler="Home"} 20
# HELP goapp_http_requests_total Count of all http requests for goapp
# TYPE goapp_http_requests_total counter
goapp_http_requests_total 20
# HELP goapp_online_users Online users
# TYPE goapp_online_users gauge
goapp_online_users{logged_users="true"} 1375

full-cycle-2.0-prometheus's People

Contributors

axellbrendow avatar

Watchers

 avatar

Forkers

natansouzaa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.