Skip to main content

Grafana Loki Logs

Log Streaming to Grafana Cloud

Following the general pattern for log streaming from applications running on CloudFlow, in this guide we give specifics for Grafana Loki.

Obtain the following information from your instance of Grafana Cloud:

Deployment

The following deployment will run the Fluentd log forwarder in your CloudFlow project, gathering logs from other pods in that same project.

grafana-loki-deployment.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: fluentd
section.io/logstream-destination: "true"
name: fluentd
namespace: default
spec:
ports:
- name: fluentdudp
port: 5160
protocol: UDP
targetPort: 5160
selector:
app: fluentd
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluentd
namespace: default
labels:
app: fluentd
spec:
replicas: 1
selector:
matchLabels:
app: fluentd
template:
metadata:
labels:
app: fluentd
section.io/logstream-collect: "false"
spec:
containers:
- name: fluentd
image: grafana/fluent-plugin-loki:master
imagePullPolicy: Always
resources:
requests:
memory: ".5Gi"
cpu: "500m"
limits:
memory: ".5Gi"
cpu: "500m"
volumeMounts:
- name: config
mountPath: /fluentd/etc/fluent.conf
readOnly: true
subPath: fluent.conf
volumes:
- name: config
configMap:
name: fluent-conf
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-conf
namespace: default
data:
fluent.conf: |-
<source>
@type udp
tag udpsource
<parse>
@type json
</parse>
port 5160
message_length_limit 1MB
</source>


<match udpsource>
@type loki
url GRAFANA_LOGGING_ENDPOINT
username GRAFANA_METRICS_INSTANCE_ID
password GRAFANA_API_KEY
extra_labels {"env":"prod"}
</match>

Apply the above resources with kubectl apply -f grafana-loki-deployment.yaml into the same project where the pods to be logged are running.

View Logs in Grafana Loki

Login to your Grafana Cloud account in order to see your logs.