To connect to your Graylog server:

1. Get the application URL by running these commands:
{{- if .Values.graylog.ingress.enabled }}
{{- range .Values.graylog.ingress.hosts }}
  http://{{ . }}
{{- end }}
{{- else if contains "NodePort" .Values.graylog.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "graylog.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.graylog.service.type }}
     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get svc -w {{ template "graylog.fullname" . }}'
  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "graylog.fullname" . }}-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  echo http://$SERVICE_IP:{{ default 9000 .Values.graylog.service.port }}
{{- else if contains "ClusterIP" .Values.graylog.service.type }}
  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "graylog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:9000 to use your application"
  kubectl port-forward $POD_NAME 9000:9000
{{- end }}

2. The Graylog root users

  echo "User: {{ .Values.graylog.rootUsername }}"
  echo "Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "graylog.fullname" . }} -o "jsonpath={.data['graylog-password-secret']}" | base64 --decode)"

To send logs to graylog:


{{- if .Values.graylog.input.tcp }}
1. TCP

{{- if contains "NodePort" .Values.graylog.input.tcp.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "graylog.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo $NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.graylog.input.tcp.service.type }}
  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "graylog.fullname" . }}-tcp -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  {{- range .Values.graylog.input.tcp.ports }}
  echo "{{ .name }} on $SERVICE_IP:{{ .port }}"
  {{- end }}

     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get svc -w {{ template "graylog.fullname" . }}-tcp'

{{- else if contains "ClusterIP" .Values.graylog.input.tcp.service.type }}
  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "graylog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
  {{- range .Values.graylog.input.tcp.ports }}
  Run the command
  kubectl port-forward $POD_NAME {{ .port }}:{{ .port }}
  Then send logs to 127.0.0.1:{{ .port }}
  {{- end }}
{{- end }}
{{- end }}
{{- if .Values.graylog.input.udp }}
2. UDP

{{- if contains "NodePort" .Values.graylog.input.udp.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo $NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.graylog.input.udp.service.type }}
  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "graylog.fullname" . }}-udp -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  {{- range .Values.graylog.input.udp.ports }}
  echo "{{ .name }} on $SERVICE_IP:{{ .port }}"
  {{- end }}

     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get svc -w {{ template "graylog.fullname" . }}-udp'

{{- else if contains "ClusterIP" .Values.graylog.input.udp.service.type }}
  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "graylog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
  {{- range .Values.graylog.input.udp.ports }}
  Run the command
  kubectl port-forward $POD_NAME {{ .port }}:{{ .port }}
  Then send logs to 127.0.0.1:{{ .port }}
  {{- end }}
{{- end }}
{{- end }}
