Fluentd is a versatile data shipper with numerous available plugins and functionalities, playing a pivotal role as a logs shipper to our platform. Below are instructions on how to set up the Fluentd shipper along with the http output plugin to transmit logs to the Coralogix platform.

## Prerequisites

Before you begin, make sure you have:

- Enabled RBAC authorization mode in your Kubernetes Cluster
- Your Coralogix [Send-Your-Data API key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key/index.md)

## Installation

To specify essential environment variables, create a configmap as shown below:

```yaml
---
## fluentd-env-cm.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/name: fluentd
    app.kubernetes.io/instance: fluentd-http
  name: fluentd-env
data:
  ENDPOINT: ingress.[[DOMAIN_VALUE]]
  LOG_LEVEL: error
```

**Notes**:

- The configmap name is crucial and utilized by the daemonSet.
- Ensure to change 'ENDPOINT' according to your logs endpoint from the table provided.

Apply the configmap:

```bash
kubectl apply -f fluentd-env-cm.yaml -n monitoring
```

Next, apply the manifest files in this directory:

```bash
kubectl apply -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-cm.yaml -n monitoring
kubectl apply -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-rbac.yaml -n monitoring
kubectl apply -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-svc.yaml -n monitoring
kubectl apply -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-ds.yaml -n monitoring
```

You should see the following output:

```text
configmap/fluentd-prometheus-conf created
configmap/fluentd-systemd-conf created
configmap/fluentd-config created
configmap/fluentd-main created
daemonset.apps/fluentd-http created
serviceaccount/fluentd-http created
clusterrole.rbac.authorization.k8s.io/fluentd-http created
clusterrolebinding.rbac.authorization.k8s.io/fluentd-http created
servicemonitor.monitoring.coreos.com/fluentd-http created
service/fluentd-http created
```

If you have the prometheus-operator installed, you can install this service monitor resource:

```bash
kubectl apply -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-svc-monitor.yaml -n monitoring
```

### Modifying applicationName and subsystemName

By default, we utilize the field `kubernetes.namespace_name` as the applicationName and `kubernetes.container_name` as the subsystemName.

#### Dynamic

To modify these values and use another field as the value of applicationName and subsystemName, modify the `fluentd-config` configmap and specifically the `coralogix.conf` key.

#### Static

To modify these values and use a hard-coded value as the value of applicationName and subsystemName, modify the `fluentd-config` configmap and specifically the `coralogix.conf` key.

### Removal

To remove all resources created with manifest files, use these commands:

```text
kubectl delete -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-cm.yaml -n monitoring
kubectl delete -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-rbac.yaml -n monitoring
kubectl delete -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-svc.yaml -n monitoring
kubectl delete -f https://raw.githubusercontent.com/coralogix/telemetry-shippers/master/logs/fluentd/k8s-manifest/fluentd-ds.yaml -n monitoring
kubectl delete -f fluentd-env-cm.yaml -n monitoring
```

The output should be:

```text
configmap "fluentd-prometheus-conf" deleted
configmap "fluentd-systemd-conf" deleted
configmap "fluentd-config" deleted
configmap "fluentd-main" deleted
daemonset.apps "fluentd-http" deleted
serviceaccount "fluentd-http" deleted
clusterrole.rbac.authorization.k8s.io "fluentd-http" deleted
clusterrolebinding.rbac.authorization.k8s.io "fluentd-http" deleted
servicemonitor.monitoring.coreos.com "fluentd-http" deleted
service "fluentd-http" deleted
configmap "fluentd-env" deleted
```

### Coralogix endpoints

Choose the https://ingress.\[[DOMAIN_VALUE]\] endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.

### Deploy to a different namespace

If you need to deploy the Fluentd integration to a namespace other than "monitoring", change the fluentd-rbac.yaml file ClusterRoleBinding namespace accordingly.

### Disable Systemd Logs

To disable the systemd logs, remove the `fluentd-systemd-conf` configmap:

```bash
kubectl delete cm fluentd-systemd-conf
```

### Dashboard

Under the `dashboard` directory, you'll find a Fluentd Grafana dashboard provided by Coralogix. To import the dashboard into Grafana, copy the JSON file content, navigate to Grafana, click on the `Create` tab, then `import`, and paste the copied JSON file.

### Coralogix Fluentd Buffer Alert

To create an alert on Fluentd buffer in Coralogix, refer to the [coralogix-alert doc](https://github.com/coralogix/telemetry-shippers/blob/master/logs/fluentd/docs/coralogix-alerts.md).

## Additional resources

|                        |                                                                                             |
| ---------------------- | ------------------------------------------------------------------------------------------- |
| External Documentation | [GitHub repository](https://github.com/coralogix/telemetry-shippers/tree/master)            |
| Coralogix Endpoints    | [Coralogix Endpoints](https://coralogix.com/docs/integrations/coralogix-endpoints/index.md) |

## **Support**

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Contact us **via our in-app chat** or by emailing [support@coralogix.com](mailto:support@coralogix.com).
