Enable New Relic Logs for Kubernetes

New Relic offers a Fluent Bit output plugin to connect your Kubernetes cluster log data to New Relic Logs. This document explains how to enable this feature.

Compatibility and requirements

To use New Relic Logs with the Kubernetes plugin, ensure your configuration meets the following requirements:

Enable Kubernetes for New Relic Logs

To enable New Relic Logs with the Fluent Bit Kubernetes plugin:

  1. Install the Kubernetes plugin.
  2. Configure the Kubernetes plugin.
  3. Generate some traffic and wait a few minutes, then check your account for data.
  4. Optional: Configure Fluent Bit parsing.

Install the Kubernetes plugin

To install the Kubernetes plugin:

  1. Navigate to the Kubernetes plugin GitHub repository.
  2. From the repository page, clone or download the repository.

Configure the Kubernetes plugin

Deploying as Helm chart (Recommended)

To deploy your Kubernetes plugin as a Helm chart:

  1. Run the following command in your terminal or command-line interface, replacing the placeholder value your-license-key with your New Relic license key:

    helm install --set licenseKey=your-license-key ./helm/newrelic-logging

    For EU users, add --set fluentBit.endpoint=https://log-api.eu.newrelic.com/log/v1 to the helm install command above.

Configure manually

To configure your Kubernetes plugin manually:

  1. In the downloaded new-relic-fluent-plugin.yml file, replace the placeholder value <LICENSE_KEY > with your New Relic license key.

    For EU users, replace the ENDPOINT environment variable to http://log-api.eu.newrelic.com/log/v1.

  2. Once the License key has been added, run the following command in your terminal or command-line interface:

    kubectl apply -f .

View log data

If everything is configured correctly and your data is being reported, you should see data logs in the New Relic Logs UI or by going to Insights and querying:

SELECT * FROM Log

Optional: Configure parsing

Once you have installed and configured the Kubernetes plugin, you can configure how the plugin parses the data. For more information, see Fluent Bit's documentation on Parsers configuration.

By default, tailing is set to /var/log/containers/*.log. To change this setting, replace the default path with your preferred path in the new-relic-fluent-plugin.yml file.

What's next?

Now that you've enabled Logs, here are some potential next steps:

Troubleshooting

Problem

You are receiving the following error:

[ warn] [filter_kube] invalid pattern for given tag

Solution

In the new-relic-fluent-plugin.yml file, replace the default code /var/log/containers/*.log with the following:

/var/log/containers/*.{log}

For more help

Recommendations for learning more: