Skip to content

Commit

Permalink
Refactoring Observability stack (#6333)
Browse files Browse the repository at this point in the history
* feat(opentelemetry): Refactoring Operator and Collector

Signed-off-by: Nicolas Lamirault <[email protected]>

* feat(argo-cd): typo

Signed-off-by: Nicolas Lamirault <[email protected]>

* feat(alloy): refactoring stack

Signed-off-by: Nicolas Lamirault <[email protected]>

* feat(opentelemetry): cleanup

Signed-off-by: Nicolas Lamirault <[email protected]>

---------

Signed-off-by: Nicolas Lamirault <[email protected]>
  • Loading branch information
nlamirault authored Feb 23, 2025
1 parent 61aa7ca commit 914cdab
Show file tree
Hide file tree
Showing 66 changed files with 1,770 additions and 694 deletions.
Binary file modified .secrets/talos/homelab/gitops/argo-cd-notifications.yaml
Binary file not shown.
37 changes: 37 additions & 0 deletions gitops/argocd/charts/opentelemetry/alloy-otel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: Copyright (C) Nicolas Lamirault <[email protected]>
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v2
type: application
name: alloy
version: 1.0.0
appVersion: 1.0.0
dependencies:
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-metrics
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-logs
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-traces
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-events
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-profiles
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 0.11.0
alias: alloy-frontend
- name: alloy-mixin
repository: oci://ghcr.io/portefaix/charts
version: 0.3.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ define "alloy.config.global" }}

// ********************************************
// * G E N E R A L
// ********************************************

local.file "cluster_name" {
filename = "/etc/alloy/cluster_name"
}

logging {
level = "info"
format = "json"
}

// tracing {
// sampling_fraction = 1
// write_to = [
// otelcol.exporter.otlp.local.input,
// // otelcol.exporter.otlp.grafana_cloud.input
// ]
// }

{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ define "alloy.config.endpoints.metrics" }}

// ********************************************
// * M E T R I C S
// ********************************************

// [Mimir Local]

prometheus.remote_write "local" {
endpoint {
url = {{ .Values.observability.metrics.prometheus | quote }}

headers = {
// "X-Scope-OrgID" = {{ .Values.observability.cluster_name | quote }},
"X-Scope-OrgID" = local.file.cluster_name.content,
}
}

external_labels = {
// cluster = {{ .Values.observability.cluster_name | quote }},
cluster = local.file.cluster_name.content,
{{- range $k, $v := .Values.observability.metrics.externalLabels }}
{{ $k }} = {{ $v | quote }},
{{- end }}
}
}

// [Grafana Cloud]

prometheus.remote_write "grafana_cloud" {
endpoint {
url = {{ .Values.observability.metrics.grafana_cloud | quote }}

basic_auth {
username = env("GRAFANA_CLOUD_METRICS_ID")
password = env("GRAFANA_CLOUD_METRICS_APIKEY")
}

headers = {
// "X-Scope-OrgID" = {{ .Values.observability.cluster_name | quote }},
"X-Scope-OrgID" = local.file.cluster_name.content,
}
}

external_labels = {
// cluster = {{ .Values.observability.cluster_name | quote }},
cluster = local.file.cluster_name.content,
{{- range $k, $v := .Values.observability.metrics.externalLabels }}
{{ $k }} = {{ $v | quote }},
{{- end }}
}
}

{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ define "alloy.config.metrics.prom_operator" }}

// ********************************************
// * P R O M E T H E U S O P E R A T O R
// ********************************************

// ServiceMonitor

prometheus.operator.servicemonitors "service_monitors" {
forward_to = [
prometheus.remote_write.local.receiver,
// prometheus.remote_write.grafana_cloud.receiver,
]

selector {
match_labels = {
monitoring = "portefaix",
}
}
}

// PodMonitor

prometheus.operator.podmonitors "pod_monitors" {
forward_to = [
prometheus.remote_write.local.receiver,
// prometheus.remote_write.grafana_cloud.receiver,
]

selector {
match_labels = {
monitoring = "portefaix",
}
}
}

// Probes

prometheus.operator.probes "probes" {
forward_to = [
prometheus.remote_write.local.receiver,
// prometheus.remote_write.grafana_cloud.receiver,
]

selector {
match_labels = {
monitoring = "portefaix",
}
}
}

{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: Copyright (C) Nicolas Lamirault <[email protected]>
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: ConfigMap
metadata:
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "alloy.labels" (index .Subcharts "alloy-metrics") | nindent 4 }}
portefaix.xyz/version: v0.54.0
name: {{ include "alloy.fullname" (index .Subcharts "alloy-metrics") }}
namespace: {{ .Release.Namespace }}
data:
cluster_name: {{ .Values.observability.cluster_name }}
config.alloy: |-
{{- include "alloy.config.global" . | indent 4}}

{{- include "alloy.config.portefaix" . | indent 4 }}

{{- include "alloy.config.endpoints.metrics" . | indent 4 }}

{{- include "alloy.config.metrics.router" . | indent 4 }}
{{- include "alloy.config.metrics.otlp" . | indent 4 }}
{{- include "alloy.config.metrics.prom_operator" . | indent 4 }}
{{- include "alloy.config.metrics.rules" . | indent 4 }}

{{- if .Values.observability.cloud.aws.enabled -}}
{{- include "alloy.config.cloud.aws" . | indent 4 }}
{{- end }}

{{- if .Values.observability.cloud.azure.enabled -}}
{{- include "alloy.config.cloud.azure" . | indent 4 }}
{{- end }}

{{- if .Values.observability.cloud.gcp.enable -}}
{{- include "alloy.config.cloud.gcp" . | indent 4 }}
{{- end }}

{{- if .Values.observability.cloud.digitalocean.enabled -}}
{{- include "alloy.config.cloud.digitalocean" . | indent 4 }}
{{- end }}

{{- if .Values.observability.cloud.scaleway.enabled -}}
{{- include "alloy.config.cloud.scaleway" . | indent 4 }}
{{- end }}
Loading

0 comments on commit 914cdab

Please sign in to comment.