Skip to content
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

Grafana Agent as OpenTelemetry Collector #4079

Merged
merged 7 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions gitops/argocd/apps/k3s/homelab/observability/grafana-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (C) Nicolas Lamirault <nicolas.lamirault@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: grafana-agent
annotations:
# https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability/#webhook-and-manifest-paths-annotation
argocd.argoproj.io/manifest-generate-paths: /gitops/argocd/charts/opentelemetry/grafana-agent
finalizers:
- resources-finalizer.argocd.argoproj.io
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent-argocd-app
app.kubernetes.io/component: grafana-agent
app.kubernetes.io/part-of: opentelemetry
spec:
destination:
namespace: opentelemetry
server: https://kubernetes.default.svc
project: portefaix-k3s-homelab
source:
path: gitops/argocd/charts/opentelemetry/grafana-agent
repoURL: https://github.com/portefaix/portefaix-kubernetes.git
targetRevision: master
helm:
skipCrds: true
valueFiles:
- values.yaml
- values-k3s-homelab.yaml
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
syncOptions:
- CreateNamespace=true
- Validate=false
- SkipDryRunOnMissingResource=true
- ApplyOutOfSyncOnly=true
# - ServerSideApply=true
# retry:
# limit: 5
# backoff:
# duration: 5s
# factor: 2
# maxDuration: 3m0s
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ resources:
# - opentelemetry-operator.yaml
# - opentelemetry-collector.yaml
# - opentelemetry-demo.yaml
- grafana-agent.yaml
# ########################### Reliability
- pyrra.yaml
- sloth.yaml
27 changes: 27 additions & 0 deletions gitops/argocd/charts/opentelemetry/grafana-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) Nicolas Lamirault <nicolas.lamirault@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v2
type: application
name: grafana-agent
version: 1.0.0
appVersion: 1.0.0
dependencies:
- name: grafana-agent
repository: https://grafana.github.io/helm-charts
version: 0.16.0
alias: grafanaAgent
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{/*
Copyright (C) Nicolas Lamirault <nicolas.lamirault@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache-2.0
*/}}

{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "grafana-agent.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "grafana-agent.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "grafana-agent.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "grafana-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "grafana-agent.labels" }}
helm.sh/chart: {{ include "grafana-agent.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: grafana-agent
app.kubernetes.io/part-of: {{ template "grafana-agent.name" . }}
{{- include "grafana-agent.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "grafana-agent.selectorLabels" }}
app.kubernetes.io/name: {{ include "grafana-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) Nicolas Lamirault <nicolas.lamirault@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: ConfigMap
metadata:
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "grafana-agent.labels" . | indent 4 }}
portefaix.xyz/version: v0.46.0
name: {{ .Values.grafanaAgent.agent.configMap.name }}
namespace: {{ .Release.Namespace }}
data:
cluster_name: {{ required ".Values.cluster.name is a required value. Please set it and try again." .Values.cluster.name }}
config.river: |-
{{- (tpl .Values.grafanaAgent.agent.configMap.content .) | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (C) Nicolas Lamirault <nicolas.lamirault@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "grafana-agent.labels" . | indent 4 }}
portefaix.xyz/version: v0.46.0
name: grafana-agent-datadog-credentials
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 1h
secretStoreRef:
kind: ClusterSecretStore
name: akeyless
target:
name: grafana-agent-datadog-credentials
creationPolicy: Owner
data:
- secretKey: DATADOG_API_KEY
remoteRef:
key: DATADOG_API_KEY
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "grafana-agent.labels" . | indent 4 }}
portefaix.xyz/version: v0.46.0
name: grafana-agent-lightstep-credentials
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 1h
secretStoreRef:
kind: ClusterSecretStore
name: akeyless
target:
name: grafana-agent-lightstep-credentials
creationPolicy: Owner
data:
- secretKey: LIGHTSTEP_TOKEN
remoteRef:
key: LIGHTSTEP_TOKEN
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "grafana-agent.labels" . | indent 4 }}
portefaix.xyz/version: v0.46.0
name: grafana-agent-grafanacloud-credentials
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 1h
secretStoreRef:
kind: ClusterSecretStore
name: akeyless
target:
name: grafana-agent-grafanacloud-credentials
creationPolicy: Owner
data:
- secretKey: GRAFANA_CLOUD_METRICS_ID
remoteRef:
key: GRAFANA_CLOUD_METRICS_ID
- secretKey: GRAFANA_CLOUD_METRICS_APIKEY
remoteRef:
key: GRAFANA_CLOUD_METRICS_APIKEY
- secretKey: GRAFANA_CLOUD_LOGS_ID
remoteRef:
key: GRAFANA_CLOUD_LOGS_ID
- secretKey: GRAFANA_CLOUD_LOGS_APIKEY
remoteRef:
key: GRAFANA_CLOUD_LOGS_APIKEY
- secretKey: GRAFANA_CLOUD_TRACES_ID
remoteRef:
key: GRAFANA_CLOUD_TRACES_ID
- secretKey: GRAFANA_CLOUD_TRACES_APIKEY
remoteRef:
key: GRAFANA_CLOUD_TRACES_APIKEY
Loading
Loading