fluent-plugin-mqtt-io icon indicating copy to clipboard operation
fluent-plugin-mqtt-io copied to clipboard

MQTT not receiving data from fluentd

Open sanashahbaz27 opened this issue 6 months ago • 0 comments

this is my configuration i am trying to send pod logs to mqtt through fluentd but mqtt is not receiving any data (connection is made successfully)

apiVersion: v1 kind: Namespace metadata: name: kube-fluentd


apiVersion: v1 kind: ServiceAccount metadata: name: kube-fluentd namespace: kube-fluentd labels: app: kube-fluentd


apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: kube-fluentd labels: app: kube-fluentd rules:

  • apiGroups:
    • "" resources:
    • pods
    • namespaces verbs:
    • get
    • list
    • watch

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: kube-fluentd roleRef: kind: ClusterRole name: kube-fluentd apiGroup: rbac.authorization.k8s.io subjects:

  • kind: ServiceAccount name: kube-fluentd namespace: kube-fluentd

apiVersion: v1 kind: ConfigMap metadata: name: fluentd-configmap namespace: kube-fluentd labels: k8s-app: fluentd-logging data: fluent.conf: |

@type tail read_from_head true tag * path /var/log/containers/*.log pos_file /var/log/fluentd-containers.log.pos # exclude_path ["/var/log/containers/fluent*"] @type regexp expression ^(?
# <filter **>
#   @type kubernetes_metadata
#   @id filter_kube_metadata
# </filter>

<match **>
  @type mqtt
  host ***.***.***.***
  port 1883
  topic test-logs
  qos 0
  retain false
  client_id fluentd-client-001
  keep_alive 60
  <format>
    @type json
    add_newline false
  </format>
</match>

<system>
 log_level debug
</system>

apiVersion: apps/v1 kind: DaemonSet metadata: name: kube-fluentd namespace: kube-fluentd labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: kube-fluentd template: metadata: labels: name: kube-fluentd spec: serviceAccountName: kube-fluentd containers: - name: kube-fluentd image: localhost:5000/fluentd-mqttnew:latest imagePullPolicy: IfNotPresent resources: limits: memory: 200Mi cpu: 100m volumeMounts: - name: varlog mountPath: /var/log - name: config-volume mountPath: /fluentd/etc env: - name: FLUENTD_ARGS value: "--no-supervisor -q" - name: FLUENT_UID value: "0" # Set UID to 0 to allow root permissions securityContext: runAsUser: 0
tolerations: - key: "node-role.kubernetes.io/master" effect: "NoSchedule" volumes: - name: varlog hostPath: path: /var/log - name: config-volume configMap: name: fluentd-configmap terminationGracePeriodSeconds: 30

  this is my DOCKERFILE:
  # Use the Fluentd base image

FROM fluent/fluentd:v1.14-1

Install the MQTT plugin

USER root RUN gem install fluent-plugin-mqtt-io RUN gem install fluent-plugin-record-reformer

Switch back to non-root user

USER fluent

Copy Fluentd configuration (optional if you want to include it in the image)

COPY fluent.conf /fluentd/etc/

Default command

CMD ["fluentd", "-c", "/fluentd/etc/fluent.conf"]

sanashahbaz27 avatar Aug 23 '24 15:08 sanashahbaz27