Skip to content

Commit

Permalink
fix: enable metrics and fb metrics config by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit-bandlamudi-nr committed Jan 30, 2025
1 parent 03b49e4 commit c0b69fa
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 51 deletions.
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-beta
appVersion: 2.1.0
home: https://github.com/newrelic/kubernetes-logging
icon: https://newrelic.com/assets/newrelic/source/NewRelic-logo-square.svg
Expand Down
1 change: 0 additions & 1 deletion charts/newrelic-logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ See [values.yaml](values.yaml) for the default values
| `fluentBit.config.extraOutputs` | Contains extra fluent-bit.conf Outputs config | |
| `fluentBit.config.parsers` | Contains parsers.conf Parsers config | |
| `fluentBit.retryLimit` | Amount of times to retry sending a given batch of logs to New Relic. This prevents data loss if there is a temporary network disruption, if a request to the Logs API is lost or when receiving a recoverable HTTP response. Set it to "False" for unlimited retries. | 5 |
| `fluentBit.sendMetrics` | Enable the collection of Fluent Bit internal metrics in Prometheus format as well as newrelic-fluent-bit-output internal plugin metrics. See [this documentation page](https://docs.newrelic.com/docs/logs/forward-logs/kubernetes-plugin-log-forwarding/#troubleshoot-installation) for more details. | `false` |
| `dnsConfig` | [DNS configuration](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config) that will be added to the pods. Can be configured also with `global.dnsConfig`. | `{}` |
| `fluentBit.criEnabled` | We assume that `kubelet`directly communicates with the container engine using the [CRI](https://kubernetes.io/docs/concepts/overview/components/#container-runtime) specification. Set this to `false` if your K8s installation uses [dockershim](https://kubernetes.io/docs/tasks/administer-cluster/migrating-from-dockershim/) instead, in order to get the logs properly parsed. | `true` |

Expand Down
33 changes: 33 additions & 0 deletions charts/newrelic-logging/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,39 @@ https://log-api.newrelic.com/log/v1
{{- end -}}
{{- end -}}

{{/*
Returns fluentbit config to collect and forward its metrics to New Relic
*/}}
{{- define "newrelic-logging.fluentBit.monitoring.config" -}}
[INPUT]
name prometheus_scrape
Alias fb-metrics-collector
host 127.0.0.1
port 2020
tag fb_metrics
metrics_path /api/v2/metrics/prometheus
scrape_interval 10s

[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
Tls.verify Off
add_label app fluent-bit
add_label source kubernetes
add_label pod_name ${HOSTNAME}
add_label node_name ${NODE_NAME}
{{- printf "add_label cluster_name %s" (include "newrelic-logging.cluster" .) | nindent 4 -}}
{{- printf "add_label namespace %s" .Release.Namespace | nindent 4 -}}
{{- printf "add_label daemonset_name %s" (include "newrelic-logging.fullname" .) | nindent 4 -}}
{{- end -}}


{{/*
Returns metricsHost
*/}}
Expand Down
4 changes: 1 addition & 3 deletions charts/newrelic-logging/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ data:
{{- if .Values.fluentBit.config.extraOutputs }}
{{- .Values.fluentBit.config.extraOutputs | nindent 4}}
{{- end }}
{{- if and (.Values.fluentBit.sendMetrics) (.Values.fluentBit.config.metricInstrumentation) }}
{{- .Values.fluentBit.config.metricInstrumentation | nindent 4}}
{{- end }}
{{- (include "newrelic-logging.fluentBit.monitoring.config" .) | nindent 4}}
parsers.conf: |
{{- if .Values.fluentBit.config.parsers }}
{{- .Values.fluentBit.config.parsers | nindent 4}}
Expand Down
2 changes: 0 additions & 2 deletions charts/newrelic-logging/templates/daemonset-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SEND_OUTPUT_PLUGIN_METRICS
value: {{ $.Values.fluentBit.sendMetrics | default "false" | quote }}
- name: METRICS_HOST
value: {{ include "newrelic-logging.metricsHost" $ | quote }}
{{- include "newrelic-logging.extraEnv" $ | nindent 12 }}
Expand Down
2 changes: 0 additions & 2 deletions charts/newrelic-logging/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SEND_OUTPUT_PLUGIN_METRICS
value: {{ $.Values.fluentBit.sendMetrics | default "false" | quote }}
- name: METRICS_HOST
value: {{ include "newrelic-logging.metricsHost" . | quote }}
{{- include "newrelic-logging.extraEnv" . | nindent 12 }}
Expand Down
13 changes: 0 additions & 13 deletions charts/newrelic-logging/tests/fluentbit_sendmetrics_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ tests:
set:
licenseKey: nr_license_key
enableWindows: true
fluentBit.sendMetrics: true
asserts:
# Linux
- contains:
Expand All @@ -31,12 +30,6 @@ tests:
fieldRef:
fieldPath: metadata.name
template: templates/daemonset.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: SEND_OUTPUT_PLUGIN_METRICS
value: "true"
template: templates/daemonset.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
Expand All @@ -60,12 +53,6 @@ tests:
fieldRef:
fieldPath: metadata.name
template: templates/daemonset-windows.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: SEND_OUTPUT_PLUGIN_METRICS
value: "true"
template: templates/daemonset-windows.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
Expand Down
32 changes: 3 additions & 29 deletions charts/newrelic-logging/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fluentBit:
k8sBufferSize: "32k"
k8sLoggingExclude: "false"
retryLimit: 5
sendMetrics: false
extraEnv: []
# extraEnv:
# - name: HTTPS_PROXY
Expand Down Expand Up @@ -166,6 +165,8 @@ fluentBit:
Allowlist_key message
Allowlist_key log
# sendMetrics is set to false by default, this has to be defaulted to true in the future, in the newrelic-fluent-bit-output plugin

outputs: |
[OUTPUT]
Name newrelic
Expand All @@ -174,7 +175,7 @@ fluentBit:
licenseKey ${LICENSE_KEY}
endpoint ${ENDPOINT}
lowDataMode ${LOW_DATA_MODE}
sendMetrics ${SEND_OUTPUT_PLUGIN_METRICS}
sendMetrics true
Retry_Limit ${RETRY_LIMIT}
# extraOutputs: |
Expand All @@ -189,33 +190,6 @@ fluentBit:
# Time_Key time
# Time_Format %Y-%m-%dT%H:%M:%S.%L
# Time_Keep On
metricInstrumentation: |
[INPUT]
name prometheus_scrape
Alias fb-metrics-collector
host 127.0.0.1
port 2020
tag fb_metrics
metrics_path /api/v2/metrics/prometheus
scrape_interval 10s
[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 cluster_name "${CLUSTER_NAME}"
add_label pod_name ${HOSTNAME}
add_label node_name ${NODE_NAME}
add_label source kubernetes

image:
repository: newrelic/newrelic-fluentbit-output
Expand Down

0 comments on commit c0b69fa

Please sign in to comment.