@marcos_feitoza/vector 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ release:
5
+ docker:
6
+ - image: circleci/node:latest
7
+ steps:
8
+ - checkout
9
+
10
+ - run:
11
+ name: Install dependencies
12
+ command: npm ci
13
+
14
+ - run:
15
+ name: Ensure full Git history
16
+ command: |
17
+ git fetch --prune --unshallow || true
18
+ git fetch --all --tags
19
+
20
+ - run:
21
+ name: Configure Git remote with GH_TOKEN
22
+ command: |
23
+ git config user.name "circleci-bot"
24
+ git config user.email "ci@users.noreply.github.com"
25
+ git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/MarcosOps/vector.git"
26
+
27
+ - run:
28
+ name: Run semantic-release
29
+ command: npx semantic-release
30
+
31
+ workflows:
32
+ release:
33
+ jobs:
34
+ - release:
35
+ context:
36
+ - shared-ci-secrets
37
+ filters:
38
+ branches:
39
+ only:
40
+ - main
41
+ - /^AB#.*/
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 1.0.0 (2026-02-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix app name ([430c934](https://github.com/MarcosOps/vector/commit/430c934004de7b0c2d6f7a00a00a06bedc589a45))
7
+ * new yaml ([b1a7085](https://github.com/MarcosOps/vector/commit/b1a7085afb1bd7ae53fc743d0198fcfd69bf40c0))
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Vector (Coletor de logs)
2
+
3
+ Este repositório entrega o Vector como DaemonSet para coleta de logs dos pods.
4
+
5
+ ## Papel na arquitetura
6
+
7
+ - Coleta `stdout/stderr` de pods no nó (`kubernetes_logs`).
8
+ - Normaliza campos e labels para consulta no Loki/Grafana.
9
+ - Encaminha para `Loki` em `http://loki.monitoring.svc.cluster.local:3100`.
10
+
11
+ ## Integração com Loki e Grafana
12
+
13
+ Fluxo:
14
+
15
+ 1. Pod escreve log em stdout/stderr.
16
+ 2. Vector captura no nó.
17
+ 3. Transform `normalize` define:
18
+ - `namespace`
19
+ - `pod`
20
+ - `container`
21
+ - `node`
22
+ - `app` (fallback por labels e nomes)
23
+ 4. Sink Loki envia payload JSON + labels.
24
+ 5. Grafana consulta Loki com LogQL e usa labels para filtros (`namespace`, `app`, `pod`, `container`).
25
+
26
+ ## Arquivos principais
27
+
28
+ - `helm/prod-values.yaml`: imagem, recursos e endpoint Loki.
29
+ - `helm/templates/configmap.yaml`: pipeline Vector (`sources`, `transforms`, `sinks`).
30
+
31
+ ## Mapeamento de label `app`
32
+
33
+ No transform atual, prioridade:
34
+
35
+ 1. `kubernetes.pod_labels.app`
36
+ 2. `kubernetes.pod_labels."app.kubernetes.io/name"`
37
+ 3. `kubernetes.pod_labels."app_kubernetes_io_name"`
38
+ 4. `kubernetes.pod_labels."app.kubernetes.io/instance"`
39
+ 5. `container`
40
+ 6. `pod`
41
+ 7. fallback `unknown`
42
+
43
+ Isso reduz casos de `app="unknown"` no Grafana.
44
+
45
+ ## Verificação rápida
46
+
47
+ - Pods do Vector:
48
+
49
+ ```bash
50
+ kubectl -n monitoring get pods -l app.kubernetes.io/name=vector -o wide
51
+ ```
52
+
53
+ - Logs do Vector:
54
+
55
+ ```bash
56
+ kubectl -n monitoring logs -l app.kubernetes.io/name=vector --tail=200
57
+ ```
58
+
59
+ - Teste no Grafana Explore (Loki):
60
+
61
+ ```logql
62
+ {namespace="app"}
63
+ ```
64
+
65
+ ou com app específico:
66
+
67
+ ```logql
68
+ {namespace="app", app=~".*crypto.*"}
69
+ ```
70
+
71
+ ## Troubleshooting comum
72
+
73
+ - Sem logs no Grafana:
74
+ - Validar endpoint do Loki no Vector.
75
+ - Conferir conectividade DNS/Service `loki.monitoring.svc.cluster.local`.
76
+ - `app=unknown`:
77
+ - Revisar labels dos Deployments.
78
+ - Ajustar fallback do transform em `configmap.yaml`.
79
+ - Alta cardinalidade:
80
+ - Evitar labels dinâmicas no app (IDs por requisição, etc.).
81
+
82
+ ## Convenções
83
+
84
+ - Logs em JSON estruturado quando possível.
85
+ - Labels estáveis: `app`, `namespace`, `pod`, `container`, `node`.
@@ -0,0 +1,6 @@
1
+ apiVersion: v2
2
+ name: vector
3
+ description: Vector daemonset to collect pod logs and send to Loki
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "0.53.0"
@@ -0,0 +1,19 @@
1
+ image:
2
+ repository: timberio/vector
3
+ tag: "0.53.0-debian"
4
+ pullPolicy: IfNotPresent
5
+
6
+ loki:
7
+ endpoint: http://loki.monitoring.svc.cluster.local:3100
8
+
9
+ resources:
10
+ requests:
11
+ cpu: 100m
12
+ memory: 128Mi
13
+ limits:
14
+ cpu: 500m
15
+ memory: 512Mi
16
+
17
+ nodeSelector: {}
18
+ tolerations: []
19
+ affinity: {}
@@ -0,0 +1,10 @@
1
+ apiVersion: rbac.authorization.k8s.io/v1
2
+ kind: ClusterRole
3
+ metadata:
4
+ name: vector
5
+ labels:
6
+ app.kubernetes.io/name: vector
7
+ rules:
8
+ - apiGroups: [""]
9
+ resources: ["pods", "namespaces", "nodes"]
10
+ verbs: ["get", "list", "watch"]
@@ -0,0 +1,14 @@
1
+ apiVersion: rbac.authorization.k8s.io/v1
2
+ kind: ClusterRoleBinding
3
+ metadata:
4
+ name: vector
5
+ labels:
6
+ app.kubernetes.io/name: vector
7
+ roleRef:
8
+ apiGroup: rbac.authorization.k8s.io
9
+ kind: ClusterRole
10
+ name: vector
11
+ subjects:
12
+ - kind: ServiceAccount
13
+ name: vector
14
+ namespace: {{ .Release.Namespace }}
@@ -0,0 +1,53 @@
1
+ apiVersion: v1
2
+ kind: ConfigMap
3
+ metadata:
4
+ name: vector-config
5
+ data:
6
+ vector.yaml: |
7
+ data_dir: /vector-data-dir
8
+
9
+ sources:
10
+ kubernetes_logs:
11
+ type: kubernetes_logs
12
+ self_node_name: ${VECTOR_SELF_NODE_NAME}
13
+
14
+ transforms:
15
+ normalize:
16
+ type: remap
17
+ inputs:
18
+ - kubernetes_logs
19
+ source: |
20
+ .namespace = .kubernetes.pod_namespace
21
+ .pod = .kubernetes.pod_name
22
+ .container = .kubernetes.container_name
23
+ .node = .kubernetes.pod_node_name
24
+ if exists(.kubernetes.pod_labels.app) && !is_null(.kubernetes.pod_labels.app) {
25
+ .app = .kubernetes.pod_labels.app
26
+ } else if exists(.kubernetes.pod_labels."app.kubernetes.io/name") && !is_null(.kubernetes.pod_labels."app.kubernetes.io/name") {
27
+ .app = .kubernetes.pod_labels."app.kubernetes.io/name"
28
+ } else if exists(.kubernetes.pod_labels."app_kubernetes_io_name") && !is_null(.kubernetes.pod_labels."app_kubernetes_io_name") {
29
+ .app = .kubernetes.pod_labels."app_kubernetes_io_name"
30
+ } else if exists(.kubernetes.pod_labels."app.kubernetes.io/instance") && !is_null(.kubernetes.pod_labels."app.kubernetes.io/instance") {
31
+ .app = .kubernetes.pod_labels."app.kubernetes.io/instance"
32
+ } else if exists(.container) && !is_null(.container) && .container != "" {
33
+ .app = .container
34
+ } else if exists(.pod) && !is_null(.pod) && .pod != "" {
35
+ .app = .pod
36
+ } else {
37
+ .app = "unknown"
38
+ }
39
+
40
+ sinks:
41
+ loki:
42
+ type: loki
43
+ inputs:
44
+ - normalize
45
+ endpoint: ${LOKI_ENDPOINT}
46
+ encoding:
47
+ codec: json
48
+ labels:
49
+ namespace: "{{`{{ namespace }}`}}"
50
+ pod: "{{`{{ pod }}`}}"
51
+ container: "{{`{{ container }}`}}"
52
+ node: "{{`{{ node }}`}}"
53
+ app: "{{`{{ app }}`}}"
@@ -0,0 +1,74 @@
1
+ apiVersion: apps/v1
2
+ kind: DaemonSet
3
+ metadata:
4
+ name: vector
5
+ labels:
6
+ app.kubernetes.io/name: vector
7
+ spec:
8
+ selector:
9
+ matchLabels:
10
+ app.kubernetes.io/name: vector
11
+ template:
12
+ metadata:
13
+ labels:
14
+ app.kubernetes.io/name: vector
15
+ spec:
16
+ serviceAccountName: vector
17
+ containers:
18
+ - name: vector
19
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
20
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
21
+ env:
22
+ - name: VECTOR_CONFIG
23
+ value: /etc/vector/vector.yaml
24
+ - name: LOKI_ENDPOINT
25
+ value: {{ .Values.loki.endpoint | quote }}
26
+ - name: VECTOR_SELF_NODE_NAME
27
+ valueFrom:
28
+ fieldRef:
29
+ apiVersion: v1
30
+ fieldPath: spec.nodeName
31
+ ports:
32
+ - name: api
33
+ containerPort: 8686
34
+ protocol: TCP
35
+ resources:
36
+ {{- toYaml .Values.resources | nindent 12 }}
37
+ volumeMounts:
38
+ - name: config
39
+ mountPath: /etc/vector
40
+ readOnly: true
41
+ - name: var-log
42
+ mountPath: /var/log
43
+ readOnly: true
44
+ - name: var-lib
45
+ mountPath: /var/lib
46
+ readOnly: true
47
+ - name: data-dir
48
+ mountPath: /vector-data-dir
49
+ volumes:
50
+ - name: config
51
+ configMap:
52
+ name: vector-config
53
+ - name: var-log
54
+ hostPath:
55
+ path: /var/log
56
+ - name: var-lib
57
+ hostPath:
58
+ path: /var/lib
59
+ - name: data-dir
60
+ hostPath:
61
+ path: /var/lib/vector
62
+ type: DirectoryOrCreate
63
+ {{- with .Values.nodeSelector }}
64
+ nodeSelector:
65
+ {{- toYaml . | nindent 8 }}
66
+ {{- end }}
67
+ {{- with .Values.affinity }}
68
+ affinity:
69
+ {{- toYaml . | nindent 8 }}
70
+ {{- end }}
71
+ {{- with .Values.tolerations }}
72
+ tolerations:
73
+ {{- toYaml . | nindent 8 }}
74
+ {{- end }}
@@ -0,0 +1,6 @@
1
+ apiVersion: v1
2
+ kind: ServiceAccount
3
+ metadata:
4
+ name: vector
5
+ labels:
6
+ app.kubernetes.io/name: vector
@@ -0,0 +1,19 @@
1
+ image:
2
+ repository: timberio/vector
3
+ tag: "0.53.0-debian"
4
+ pullPolicy: IfNotPresent
5
+
6
+ loki:
7
+ endpoint: http://loki.monitoring.svc.cluster.local:3100
8
+
9
+ resources:
10
+ requests:
11
+ cpu: 100m
12
+ memory: 128Mi
13
+ limits:
14
+ cpu: 500m
15
+ memory: 512Mi
16
+
17
+ nodeSelector: {}
18
+ tolerations: []
19
+ affinity: {}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@marcos_feitoza/vector",
3
+ "version": "1.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "scripts": {
8
+ "release": "semantic-release"
9
+ },
10
+ "devDependencies": {
11
+ "semantic-release": "^18.0.0",
12
+ "@semantic-release/changelog": "^6.0.0",
13
+ "@semantic-release/git": "^10.0.0",
14
+ "@semantic-release/github": "^8.0.0"
15
+ },
16
+ "release": {
17
+ "branches": [
18
+ "main"
19
+ ],
20
+ "plugins": [
21
+ "@semantic-release/commit-analyzer",
22
+ "@semantic-release/release-notes-generator",
23
+ "@semantic-release/changelog",
24
+ "@semantic-release/npm",
25
+ "@semantic-release/github",
26
+ "@semantic-release/git"
27
+ ]
28
+ }
29
+ }