|
| 1 | +## Setup |
| 2 | + |
| 3 | +Una máquina Linux con Docker instalado |
| 4 | + |
| 5 | + |
| 6 | +```Vagrantfile |
| 7 | +Vagrant.configure("2") do |config| |
| 8 | + config.vm.box = "bento/ubuntu-20.04" |
| 9 | + config.vm.network "private_network", ip: "10.0.0.10" |
| 10 | + config.vm.provision "docker" |
| 11 | +end |
| 12 | +``` |
| 13 | + |
| 14 | +> Esta máquina será accesible desde el `host` en la dirección `10.0.0.10` |
| 15 | +
|
| 16 | +Para arrancar la VM |
| 17 | + |
| 18 | +```bash |
| 19 | +vagrant up |
| 20 | +``` |
| 21 | + |
| 22 | +Para acceder a la VM |
| 23 | + |
| 24 | +```bash |
| 25 | +vagrant ssh |
| 26 | +``` |
| 27 | + |
| 28 | +## 1. Proceso Batch |
| 29 | + |
| 30 | +Vamos a utilizar la app que hemos generado en las demos anteriores. |
| 31 | + |
| 32 | +```bash |
| 33 | +docker run -d --name batch \ |
| 34 | + -e PORT="8080" \ |
| 35 | + -p 8080:8080 \ |
| 36 | + jaimesalas/prom-batch |
| 37 | + |
| 38 | +docker logs batch |
| 39 | +``` |
| 40 | + |
| 41 | +> Navegar a http://10.0.0.10:8080/metrics |
| 42 | +
|
| 43 | +### Custom application metrics |
| 44 | + |
| 45 | +- `worker_jobs_active` es un _Gauge_, cuando refrescamos podemos ver como el valor sube y baja |
| 46 | +- `worker_jobs_total` es un _Counter_, los números siempre aumentan, el `counter` también tiene etiquetas para registrar las variaciones. |
| 47 | + |
| 48 | +### Node metrics |
| 49 | + |
| 50 | +- `nodejs_heap_size_used_bytes` - El tamaño de heap usado por el proceso de Node.js. |
| 51 | +- `process_cpu_seconds_total` - Tiempo total de CPU gastado por el sistema y el usuario. |
| 52 | + |
| 53 | +## 2. - Node Exporter |
| 54 | + |
| 55 | +Descargar y extraer [Node Exporter](https://github.com/prometheus/node_exporter): |
| 56 | + |
| 57 | +``` |
| 58 | +wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz |
| 59 | +
|
| 60 | +tar xvfz node_exporter-1.3.1.linux-amd64.tar.gz |
| 61 | +
|
| 62 | +cd node_exporter-1.3.1.linux-amd64/ |
| 63 | +``` |
| 64 | + |
| 65 | +Ejecutar (normalmente será un daemon): |
| 66 | + |
| 67 | +``` |
| 68 | +./node_exporter |
| 69 | +``` |
| 70 | + |
| 71 | +> Browse to http://10.0.0.10:9100/metrics |
| 72 | +
|
| 73 | +### Hay métricas de hardware/OS |
| 74 | + |
| 75 | +- `node_disk_io_time_seconds_total` - es un contador con la etiqueta `name` |
| 76 | +- `node_cpu_seconds_total` - tiene etiquetas para el CPU core y el modo de trabajo |
| 77 | +- `node_filesystem_avail_bytes` - es un gauge con el espacio en disco libre |
| 78 | + |
| 79 | +### Y métricas de mera información |
| 80 | + |
| 81 | +- `node_uname_info` - devuelve texto que da información de la version |
0 commit comments