-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Iac observability stack (Jaeger, Prometheus, Alertmanager, Grafana and Loki and Configuration Kind Cluster #3
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,142 @@ | ||||||
# Observability Stack | ||||||
|
||||||
Este repositório contém uma stack completa de ferramentas de observabilidade, configurada utilizando o Docker Compose (versão 3.9). Abaixo estão os serviços incluídos e suas respectivas funcionalidades. | ||||||
|
||||||
## Serviços Disponíveis | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Para quem tiver interesse em estudar outras ferramentas, poderia ser interessante utilizar os serviços da Grafana Stack (Loki, Tempo e Mimir). Pretendo criar os arquivos de configuração para essa stack sugerida e abro um PR posteriormente. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acho uma boa opção dar visão a mais ferramentas |
||||||
|
||||||
### 1. **Jaeger** | ||||||
|
||||||
**Imagem:** `jaegertracing/all-in-one:latest` | ||||||
|
||||||
**Descrição:** | ||||||
- Ferramenta de rastreamento distribuído para monitorar fluxos de requisições entre microserviços. | ||||||
- Permite identificar gargalos e falhas na comunicação entre serviços. | ||||||
|
||||||
**Portas Explicadas:** | ||||||
- `5775/udp`: Para clientes que enviam spans via UDP. | ||||||
- `5778`: Endpoint para configuração de cliente (HTTP). | ||||||
- `16686`: Interface web para visualizar rastreamentos. | ||||||
- `14250`: Endpoint gRPC para clientes OpenTelemetry. | ||||||
- `14268`: Endpoint HTTP para clientes OpenTelemetry. | ||||||
- `14269`: Endpoint para métricas. | ||||||
|
||||||
### 2. **Prometheus** | ||||||
|
||||||
**Imagem:** `prom/prometheus:latest` | ||||||
|
||||||
**Descrição:** | ||||||
- Ferramenta para coleta e consulta de métricas, amplamente utilizada para monitoramento de sistemas. | ||||||
- Configurado para utilizar um arquivo customizado (`prometheus.yml`). | ||||||
|
||||||
**Portas Explicadas:** | ||||||
- `9090`: Interface web do Prometheus para consultas e monitoramento. | ||||||
|
||||||
**Volumes Montados:** | ||||||
- `./infra/docker/prometheus.yml:/etc/prometheus/prometheus.yml`: Arquivo de configuração do Prometheus. | ||||||
|
||||||
### 3. **Alertmanager** | ||||||
|
||||||
**Imagem:** `prom/alertmanager:latest` | ||||||
|
||||||
**Descrição:** | ||||||
- Sistema de gerenciamento de alertas do Prometheus, permitindo notificações via e-mail, Slack e outros canais. | ||||||
- Configurado para utilizar um arquivo customizado (`alertmanager.yml`). | ||||||
|
||||||
**Portas Explicadas:** | ||||||
- `9093`: Interface web para gerenciamento de alertas. | ||||||
|
||||||
**Volumes Montados:** | ||||||
- `./infra/docker/alertmanager.yml:/etc/alertmanager/alertmanager.yml`: Arquivo de configuração do Alertmanager. | ||||||
|
||||||
### 4. **Grafana** | ||||||
|
||||||
**Imagem:** `grafana/grafana-oss:latest` | ||||||
|
||||||
**Descrição:** | ||||||
- Plataforma para visualização de métricas, logs e rastreamentos, com suporte para integrações como Prometheus, Loki e Jaeger. | ||||||
|
||||||
**Portas Explicadas:** | ||||||
- `3000`: Interface web do Grafana para criação de dashboards e visualização de dados. | ||||||
|
||||||
**Ambiente Configurado:** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acredito que podemos utiliza a env no dockerfile para habilitar o login anonimo do Grafana. Isso evita pequenas confusões para os usuários.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ótima sugestão |
||||||
- Usuário administrador: `admin`. | ||||||
- Senha: `admin`. | ||||||
|
||||||
**Volumes Montados:** | ||||||
- `grafana-data:/var/lib/grafana`: Diretório persistente para dados do Grafana. | ||||||
|
||||||
### 5. **Loki** | ||||||
|
||||||
**Imagem:** `grafana/loki:latest` | ||||||
|
||||||
**Descrição:** | ||||||
- Sistema de agregação e consulta de logs, projetado para trabalhar junto com o Grafana. | ||||||
- Configurado para utilizar um arquivo customizado (`loki-config.yml`). | ||||||
|
||||||
**Portas Explicadas:** | ||||||
- `3100`: Endpoint de consulta de logs. | ||||||
|
||||||
**Volumes Montados:** | ||||||
- `./infra/docker/loki-config.yml:/etc/loki/local-config.yaml`: Arquivo de configuração do Loki. | ||||||
- `loki-data:/loki-data`: A onde os dados são armazenados. | ||||||
|
||||||
## Volumes Persistentes | ||||||
|
||||||
Os seguintes volumes são utilizados para armazenar dados de forma persistente: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Por se tratar de um ambiente de teste, acha necessário persistir dados? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eu acho relevante os seguintes pontos para um ambiente local:
Dado a esses pontos e a capacidade simplista de remover volumes do docker (docker volume prune -f), não vejo o motivo do porque "não manter" volumes persistentes pré definidos, e a facilidade de remoção desses volumes no manifesto do docker compose caso não deseje é simples, porém para atender o ponto que você trouxe e a minha observação, podemos manter as seguintes opções (minha percepção)
Acho que ambos são validos e englobaria ambos os cenários e traria facilidade para quem for utilizar |
||||||
- `jaeger-data`: Dados do Jaeger. | ||||||
- `prometheus-data`: Dados do Prometheus. | ||||||
- `grafana-data`: Dados do Grafana. | ||||||
- `loki-data`: Dados do Loki. | ||||||
|
||||||
## Como Utilizar | ||||||
|
||||||
1. Certifique-se de ter o Docker e Docker Compose instalados em sua máquina. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acha interessante adicionar um tópico de pré-requisitos com os links de instalação do docker e docker-compose?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sugiro também colocar os links das documentações de todas as ferramentas utilizadas, através de um tópico de Referências. Referências:[Docker] (https://docs.docker.com/manuals/) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pode fazer sentido sim !! |
||||||
2. Clone este repositório: | ||||||
```bash | ||||||
git clone [email protected]:dosedetelemetria/projeto-otel-na-pratica.git | ||||||
cd iac | ||||||
``` | ||||||
3. Suba os serviços com o comando: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
```bash | ||||||
docker-compose up -d | ||||||
``` | ||||||
4. Acesse as interfaces web dos serviços: | ||||||
- **Jaeger:** [http://localhost:16686](http://localhost:16686) | ||||||
- **Prometheus:** [http://localhost:9090](http://localhost:9090) | ||||||
- **Alertmanager:** [http://localhost:9093](http://localhost:9093) | ||||||
- **Grafana:** [http://localhost:3000](http://localhost:3000) | ||||||
|
||||||
## Finalidade de Cada Serviço | ||||||
|
||||||
- **Jaeger:** Rastreamento distribuído. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sugestão você pode migrar esse bloco com as descrições para tópico 4,
Suggested change
|
||||||
- **Prometheus:** Coleta de métricas. | ||||||
- **Alertmanager:** Gerenciamento de alertas. | ||||||
- **Grafana:** Visualização de métricas, logs e rastreamentos. | ||||||
- **Loki:** Armazenamento e consulta de logs. | ||||||
|
||||||
Com esta configuração, você terá uma stack de observabilidade completa para monitorar sistemas em desenvolvimento. | ||||||
|
||||||
## Instalação e Uso do Kind (Kubernetes in Docker) | ||||||
|
||||||
Para configurar um cluster Kubernetes local usando o Kind (Kubernetes in Docker), siga as instruções abaixo: | ||||||
|
||||||
### Instalar o Kind | ||||||
1. Certifique-se de ter o Docker instalado e em execução. | ||||||
2. Baixe e instale o Kind executando o seguinte comando: | ||||||
```bash | ||||||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 | ||||||
chmod +x ./kind | ||||||
sudo mv ./kind /usr/local/bin/kind | ||||||
``` | ||||||
|
||||||
### Criar um Cluster com o Kind | ||||||
1. Certifique-se de que o arquivo `kind.yaml` está no diretório que será chamado | ||||||
2. Execute o comando para criar um cluster Kubernetes com múltiplos nós: | ||||||
```bash | ||||||
kind create cluster --name=multi-node-cluster --config=kind.yaml | ||||||
``` | ||||||
3. Verifique se o cluster foi criado com sucesso: | ||||||
```bash | ||||||
kubectl get nodes | ||||||
``` | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
global: | ||
resolve_timeout: 5m | ||
|
||
route: | ||
receiver: "default" | ||
|
||
receivers: | ||
- name: "default" |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||||
version: '3.9' | ||||||||
|
||||||||
services: | ||||||||
jaeger: | ||||||||
image: jaegertracing/all-in-one:latest | ||||||||
container_name: jaeger | ||||||||
ports: | ||||||||
- "5775:5775/udp" | ||||||||
- "5778:5778" | ||||||||
- "16686:16686" | ||||||||
- "14250:14250" | ||||||||
- "14268:14268" | ||||||||
- "14269:14269" | ||||||||
|
||||||||
prometheus: | ||||||||
image: prom/prometheus:latest | ||||||||
container_name: prometheus | ||||||||
volumes: | ||||||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||||||||
ports: | ||||||||
- "9090:9090" | ||||||||
command: | ||||||||
- "--config.file=/etc/prometheus/prometheus.yml" | ||||||||
|
||||||||
alertmanager: | ||||||||
image: prom/alertmanager:latest | ||||||||
container_name: alertmanager | ||||||||
volumes: | ||||||||
- ./alertmanager.yml:/etc/alertmanager/alertmanager.yml | ||||||||
ports: | ||||||||
- "9093:9093" | ||||||||
command: | ||||||||
- "--config.file=/etc/alertmanager/alertmanager.yml" | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aqui tem uma linha a mais.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Podemos contribuir com um pré commit que faça lint nos arquivos para melhorar espaçamentos e comentários |
||||||||
|
||||||||
grafana: | ||||||||
image: grafana/grafana-oss:latest | ||||||||
container_name: grafana | ||||||||
ports: | ||||||||
- "3000:3000" | ||||||||
environment: | ||||||||
- GF_SECURITY_ADMIN_USER=admin | ||||||||
- GF_SECURITY_ADMIN_PASSWORD=admin | ||||||||
Comment on lines
+42
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validar antes.
Suggested change
|
||||||||
volumes: | ||||||||
- grafana-data:/var/lib/grafana | ||||||||
|
||||||||
loki: | ||||||||
image: grafana/loki:latest | ||||||||
container_name: loki | ||||||||
ports: | ||||||||
- "3100:3100" | ||||||||
command: -config.file=/etc/loki/local-config.yaml | ||||||||
volumes: | ||||||||
- loki-data:/loki-data | ||||||||
- ./loki-config.yml:/etc/loki/local-config.yaml | ||||||||
|
||||||||
volumes: | ||||||||
jaeger-data: {} | ||||||||
prometheus-data: {} | ||||||||
grafana-data: {} | ||||||||
loki-data: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
server: | ||
http_listen_port: 3100 | ||
|
||
common: | ||
path_prefix: /tmp/loki | ||
storage: | ||
filesystem: | ||
chunks_directory: /tmp/loki/chunks | ||
rules_directory: /tmp/loki/rules | ||
replication_factor: 1 | ||
ring: | ||
instance_addr: 127.0.0.1 | ||
kvstore: | ||
store: inmemory | ||
|
||
schema_config: | ||
configs: | ||
- from: 2020-09-07 | ||
store: tsdb | ||
object_store: filesystem | ||
schema: v13 | ||
index: | ||
prefix: loki_index_ | ||
period: 24h | ||
|
||
limits_config: | ||
allow_structured_metadata: false | ||
|
||
compactor: | ||
working_directory: /tmp/loki/compactor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
global: | ||
scrape_interval: 15s | ||
|
||
scrape_configs: | ||
- job_name: 'jaeger' | ||
static_configs: | ||
- targets: ['jaeger:14269'] | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['localhost:9090'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alguem motivo para remover os manifestos ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aloisiobilck eu sugeri uma outra estrutura de pastas, dividindo na pasta docker e k8s, então o README fica dentro do seu respectivo contexto