Skip to content

Commit

Permalink
Add Grafana, Loki, and Prometheus for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-maddy committed Sep 14, 2024
2 parents 0621e62 + a3548e2 commit f604b2d
Show file tree
Hide file tree
Showing 25 changed files with 1,089 additions and 9 deletions.
15 changes: 12 additions & 3 deletions kubernetes/chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
dependencies:
- name: ingress-nginx
repository: https://kubernetes.github.io/ingress-nginx/
repository: https://kubernetes.github.io/ingress-nginx
version: 4.7.1
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.12.0
digest: sha256:57ebed200798be88cffe7363c99d2dd6bc252189aa756ec38803b9d83345cd95
generated: "2023-07-15T10:28:49.9366857-05:00"
- name: metrics-server
repository: https://kubernetes-sigs.github.io/metrics-server
version: 3.12.1
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.6.1
- name: loki
repository: https://grafana.github.io/helm-charts
version: 6.10.0
digest: sha256:d42ee79ea1318303a8b53d9b40bc0fe9e7c7606e4def1e6697339a1d72c10cc7
generated: "2024-08-25T12:55:08.762116+05:30"
14 changes: 12 additions & 2 deletions kubernetes/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ appVersion: 0.1.0

dependencies:
- name: ingress-nginx
repository: https://kubernetes.github.io/ingress-nginx
version: 4.7.1
repository: https://kubernetes.github.io/ingress-nginx/
- name: cert-manager
version: v1.12.0
repository: https://charts.jetstack.io
version: v1.12.0
condition: cert-manager.enabled
- name: metrics-server
repository: https://kubernetes-sigs.github.io/metrics-server
version: 3.12.1
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.6.1
- name: loki
repository: https://grafana.github.io/helm-charts
version: 6.10.0
condition: loki.enabled
4 changes: 0 additions & 4 deletions kubernetes/chart/production.yaml

This file was deleted.

194 changes: 194 additions & 0 deletions kubernetes/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
---
cert-manager:
enabled: true

installCRDs: true

namespace: cert-manager

ingress-nginx:
controller:
metrics:
enabled: true

loki:
enabled: false

deploymentMode: SingleBinary

loki:
image:
digest: sha256:cb233dada1ac1ab09b5fee5e99a081c3f0580c37863516daa02bc927cd8cadd8 # 3.0.1

# Disable auth, since we are in-cluster
auth_enabled: false

commonConfig:
replication_factor: 1

storage:
type: filesystem

schemaConfig:
configs:
- from: 2024-01-01
store: tsdb
object_store: filesystem # NOTE!: Since we're storing on the filesystem, there's no real persistence here
schema: v13
index:
prefix: loki_index_
period: 24h

test:
enabled: false

lokiCanary:
enabled: false

gateway:
enabled: false

ingress:
enabled: true

ingressClassName: nginx

hosts:
- loki.vipyrsec.com

singleBinary:
replicas: 1

persistence:
size: 10Gi

write:
replicas: 0

read:
replicas: 0

backend:
replicas: 0

ruler:
enabled: false

memcachedExporter:
enabled: false

resultsCache:
enabled: false

chunksCache:
enabled: false

alloy:
enabled: false

image:
digest: sha256:2381097248235e37c34a727103cf9ad0e11767defdab6f37646cff09acd2dbaf # v1.3.1

alloy:
configMap:
content: |-
logging {
level = "info"
format = "logfmt"
}
discovery.kubernetes "pods" {
role = "pod"
}
discovery.relabel "pods" {
targets = discovery.kubernetes.pods.targets
rule {
source_labels = ["__meta_kubernetes_namespace"]
action = "replace"
target_label = "namespace"
}
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"]
action = "replace"
target_label = "app"
}
rule {
source_labels = ["__meta_kubernetes_pod_name"]
action = "replace"
target_label = "pod"
}
rule {
source_labels = ["__meta_kubernetes_pod_container_name"]
action = "replace"
target_label = "container"
}
}
loki.source.kubernetes "pod_logs" {
targets = discovery.relabel.pods.output
forward_to = [loki.process.pod_logs.receiver]
}
loki.process "pod_logs" {
stage.static_labels {
values = {
cluster = "o11y",
}
}
forward_to = [loki.write.o11y.receiver]
}
loki.write "o11y" {
endpoint {
url = "http://vipyrsec-loki.default.svc.cluster.local:3100/loki/api/v1/push"
}
}
prometheus.exporter.self "local" { }
prometheus.exporter.unix "local" { }
prometheus.exporter.cadvisor "local" { }
prometheus.scrape "self" {
targets = prometheus.exporter.self.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "node" {
targets = prometheus.exporter.unix.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "cadvisor" {
targets = prometheus.exporter.cadvisor.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "pods" {
targets = discovery.relabel.pods.output
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.relabel "tagged" {
rule {
source_labels = ["__address__"]
regex = ".*"
replacement = "o11y"
target_label = "cluster"
}
forward_to = [prometheus.remote_write.o11y.receiver]
}
prometheus.remote_write "o11y" {
endpoint {
url = "http://prometheus.prometheus.svc.cluster.local:9090/api/v1/write"
}
}
110 changes: 110 additions & 0 deletions kubernetes/chart/values/local/vipyrsec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
loki:
enabled: true

alloy:
enabled: true

alloy:
configMap:
content: |-
logging {
level = "info"
format = "logfmt"
}
discovery.kubernetes "pods" {
role = "pod"
}
discovery.relabel "pods" {
targets = discovery.kubernetes.pods.targets
rule {
source_labels = ["__meta_kubernetes_namespace"]
action = "replace"
target_label = "namespace"
}
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"]
action = "replace"
target_label = "app"
}
rule {
source_labels = ["__meta_kubernetes_pod_name"]
action = "replace"
target_label = "pod"
}
rule {
source_labels = ["__meta_kubernetes_pod_container_name"]
action = "replace"
target_label = "container"
}
}
loki.source.kubernetes "pod_logs" {
targets = discovery.relabel.pods.output
forward_to = [loki.process.pod_logs.receiver]
}
loki.process "pod_logs" {
stage.static_labels {
values = {
cluster = "local",
}
}
forward_to = [loki.write.o11y.receiver]
}
loki.write "o11y" {
endpoint {
url = "http://vipyrsec-loki.default.svc.cluster.local:3100/loki/api/v1/push"
}
}
prometheus.exporter.self "local" { }
prometheus.exporter.unix "local" { }
prometheus.exporter.cadvisor "local" { }
prometheus.scrape "self" {
targets = prometheus.exporter.self.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "node" {
targets = prometheus.exporter.unix.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "cadvisor" {
targets = prometheus.exporter.cadvisor.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "pods" {
targets = discovery.relabel.pods.output
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.relabel "tagged" {
rule {
source_labels = ["__address__"]
regex = ".*"
replacement = "local"
target_label = "cluster"
}
forward_to = [prometheus.remote_write.o11y.receiver]
}
prometheus.remote_write "o11y" {
endpoint {
url = "http://prometheus.prometheus.svc.cluster.local:9090/api/v1/write"
}
}
Loading

0 comments on commit f604b2d

Please sign in to comment.