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

[newrelic-logging] add labels to metrics output to enable entity synthesis #1547

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion charts/newrelic-logging/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: A Helm chart to deploy New Relic Kubernetes Logging as a DaemonSet, supporting both Linux and Windows nodes and containers
name: newrelic-logging
version: 1.23.5
version: 1.23.6
appVersion: 2.1.0
home: https://github.com/newrelic/kubernetes-logging
icon: https://newrelic.com/assets/newrelic/source/NewRelic-logo-square.svg
Expand Down
10 changes: 10 additions & 0 deletions charts/newrelic-logging/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ https://log-api.newrelic.com/log/v1
{{- end -}}
{{- end -}}


{{/*
Creates labels required for entity synthesis to be put as part of prometheus_remote_write configuration
*/}}
{{- define "newrelic-logging.entitySynthesis.labels" -}}
{{- printf "add_label cluster_name %s" (include "newrelic-logging.cluster" .) | nindent 8 -}}
{{- printf "add_label namespace %s" .Release.Namespace | nindent 8 -}}
{{- printf "add_label daemonset_name %s" (include "newrelic-logging.fullname" .) | nindent 8 -}}
{{- end -}}

{{/*
Returns metricsHost
*/}}
Expand Down
3 changes: 2 additions & 1 deletion charts/newrelic-logging/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ data:
{{- .Values.fluentBit.config.extraOutputs | nindent 4}}
{{- end }}
{{- if and (.Values.fluentBit.sendMetrics) (.Values.fluentBit.config.metricInstrumentation) }}
{{- .Values.fluentBit.config.metricInstrumentation | nindent 4}}
{{- .Values.fluentBit.config.metricInstrumentation | nindent 4 -}}
{{ include "newrelic-logging.entitySynthesis.labels" . }}
{{- end }}
parsers.conf: |
{{- if .Values.fluentBit.config.parsers }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
suite: test fluent-bit entity synthesis labels include
templates:
- templates/configmap.yaml
release:
name: my-release
namespace: my-namespace
tests:
- it: "additional labels for entity synthesis are included when sendMetrics is set to true"
templates:
- templates/configmap.yaml
set:
fluentBit:
sendMetrics: true
config:
metricInstrumentation: |
[OUTPUT]
Name prometheus_remote_write
Match fb_metrics
Alias fb-metrics-forwarder
Host ${METRICS_HOST}
Port 443
Uri /prometheus/v1/write?prometheus_server=${CLUSTER_NAME}
Header Authorization Bearer ${LICENSE_KEY}
Tls On
# Windows pods using prometheus_remote_write currently have issues if TLS verify is On
Tls.verify Off
# User-defined labels
add_label app fluent-bit
add_label pod_name ${HOSTNAME}
add_label node_name ${NODE_NAME}
add_label source kubernetes
asserts:
- matchRegex:
path: data["fluent-bit.conf"]
pattern: (?s)add_label\s+cluster_name \n\s*add_label\s+namespace my-namespace\n\s*add_label\s+daemonset_name my-release-newrelic-logging
- it: "additional labels for entity synthesis are not included when sendMetrics is set to false"
templates:
- templates/configmap.yaml
set:
fluentBit:
sendMetrics: false
config:
metricInstrumentation: |
[OUTPUT]
Name prometheus_remote_write
Match fb_metrics
Alias fb-metrics-forwarder
Host ${METRICS_HOST}
Port 443
Uri /prometheus/v1/write?prometheus_server=${CLUSTER_NAME}
Header Authorization Bearer ${LICENSE_KEY}
Tls On
# Windows pods using prometheus_remote_write currently have issues if TLS verify is On
Tls.verify Off
# User-defined labels
add_label app fluent-bit
add_label pod_name ${HOSTNAME}
add_label node_name ${NODE_NAME}
add_label source kubernetes
asserts:
- notMatchRegex:
path: data["fluent-bit.conf"]
pattern: (?s)add_label\s+cluster_name \n\s*add_label\s+namespace my-namespace\n\s*add_label\s+daemonset_name my-release-newrelic-logging
1 change: 0 additions & 1 deletion charts/newrelic-logging/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ fluentBit:
Tls.verify Off
# User-defined labels
add_label app fluent-bit
add_label cluster_name "${CLUSTER_NAME}"
add_label pod_name ${HOSTNAME}
add_label node_name ${NODE_NAME}
add_label source kubernetes
Expand Down
Loading